jgeisler0303 / PIC16F1454_USB2Serial

PIC 16F1454 USB to Serial Adapter Firmware
18 stars 10 forks source link

Arduino IDE #4

Open svencov opened 1 year ago

svencov commented 1 year ago

Did you ever get this to work inside the Arduino IDE? I've assembled everything so far and can program PIC via ICSP however I am having difficulty programming the Atmega328 chip via the Arduino IDE. The Arduino IDE serial monitor is working (displaying values sent by the Atmega328 so I know the PIC is doing something).

jgeisler0303 commented 1 year ago

Did you flash the atmega with a bootloader? Here are the instructions: In order to make our Atmega Arduino-compatible you have to flash it with an Arduino bootloader. To do this, you can use a second Arduino board and follow these instructions.

In the Arduino IDE you have to choose "Arduino as ISP" for the programmer and "Arduino Duemilanove w/ Atmega328" as the board.

svencov commented 1 year ago

Yes, I flashed the bootloader (and the blink example) via ICSP.

Thanks for the suggestion to upload via programmer and "Arduino as ISP" as the programmer with "Arduino Duemilanove." I wonder if the IDE has changed at all. Still not working.

Sounds like you have used the Arduino IDE to upload in the past? Maybe there's an old edition of the IDE I could upload?

Here's the error I'm getting...

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Lenovo ThinkPad\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x96

I know the chip is working because I've uploaded serial code to the Atmega via ICSP and the serial monitor lights up.

svencov commented 1 year ago

Here is a short video of the hardware.

https://github.com/jgeisler0303/PIC16F1454_USB2Serial/assets/24260113/08adb6a5-de0e-4da1-af5d-a0e665e94266

jgeisler0303 commented 1 year ago

If the atmega is working and sending serial data via the PIC, then I can only suggest to put the atmega into a known-working arduino board and see if it is programmable via the serial interface there. But it looks like you soldered the atmega chip onto the proto-board. Then that's not going to work.

I used the IDE many times to program all different kinds of arduino boards. It is important to select the right board and programmer type.

Did you wire the chip reset line from the DTR of the PIC to the atmega?

svencov commented 1 year ago

Yes, soldered the Atmega. May be able unsolder the TX and RX lines if need be. Yes, the DTR is connected to the PIC via a 100nF capacitor.

svencov commented 1 year ago

I tried Arduino as ISP, Arduino as ISP (atmega32u4), ArduinoISP, ArduinoISP.org, AVRISP, and AVRISP mkII and no successful connection. Could you help my understanding with what might be the location of the error? Is it a driver issue? Maybe a ATmega issue (though I've been able to burn the boot loader and upload an example program to the AtMega via a USBasp programmer and ICSP pins)? Maybe an issue with the PIC code (the PIC is performing serial to USB).

Video of an upload. https://youtu.be/nGJnWUEl9W0

jgeisler0303 commented 1 year ago

I just tried again with my board and it works with the same settings as yours.

My understanding is that there is nothing magic in the serial comm during the upload. Therefore, since the serial seems to be working, the problem must be in the bootloader.

You could verify this with an alternative serial connection to the atmega chip wired up with DTR. If it doesn't work then it probably is the the bootloader.

Then you could re-burn the Duemilanova Bootloader to the atmega.

svencov commented 1 year ago

That is good news, well not as good as Jesus dying for our sins, but, nevertheless, I was worried the newer IDE had changed something. Sweet, I'll see about maybe reflashing the Atmega with the boot loader and maybe trying to connect another Atmega to my setup if need be (I've got a bread board set up for a Atmega)

svencov commented 1 year ago

I'm also slightly wondering about the resistors I placed in the TX and RX lines. I used 1k ohm because the Arduino nano uses 1k ohm and I believe others use 220 ohm, maybe an issue?

svencov commented 1 year ago

@jgeisler0303 Bro, thank you so much. I uploaded the wrong boot loader. I uploaded the Uno bootloader. I uploaded the Duemilanove bootloader and the board is uploading. Thank you so much, you're a blessing!

svencov commented 1 year ago

@jgeisler0303 I'm super thankful! I want to send you one of the first kits being made as a thank you! I've been developing this project for students in Zimbabwe! The students will be able to learn to solder and learn about basic electronics components (I'm going to write an educational instruction manual). I really appreciate you taking the time to help me and I appreciate the work you've put into the project. Would you be willing to email me your mailing address? Would be grateful for the ability to send you thanks!

Here's my junk email (that way the bots remain unhappy): svencove@gmail.com

jgeisler0303 commented 1 year ago

Hi @svencov , good to hear it's working now!

You cannot imagine how happy I am that my work is being put to good use. You might have noticed how old and almost abandoned the project is. And honestly I had my doubts that using an expensive PIC with all the hassle of flashing it, instead of a simple ch340, only to have a through-hole component, is worth it.

I must admit that I already have more than enough hardware sitting around in my shelf, collecting dust. And I'm not so much attached to physical tokens. Therefore I would like to thankfully decline your offer. Your reply and your story is thanks enough! I'd really like to know how your project works out, as I am also working in education. So, feel free to keep me posted.