Problem Uploading code in Custom Board Atmega328P U-TH

Thread Starter

pablo.gonzalez.iei@gmail.

Joined Jun 8, 2021
5
Hi all!

I made a board based in Arduino and some other designs with an Atmega328P U-TH and a USB type C with the serial CH340P.
The first problem I have is that I can't upload code thru the USB, even tho my computer recognizes the port and the ch340p (so no problem with drivers).
I managed to upload the "Blink" sketch with a Polulu programer thru ISP and Arduino IDE.
The second problem comes when I try to use a Bluetooth module. I use a DSD module (SH-HC-08) and some apps (Serial Bluetooth Terminal and LightBlue). The Bluetooth can receive data but not send it. For example, I can turn on a led typing "1" in Serial Monitor and the app receive it, but if I type it in the app, nothing happens.
I have tried connecting the Bluetooth with external power. It could be the RX pin so I used SoftwareSerial.h with no luck.
I have attached the PCB schematic, the code used and what I see in the app Serial Bluetooth Terminal.
The Bluetooth connections are:
VCC --> 3.3V
GND --> GND
TXD --> RXI
RXD --> TXO
 

Attachments

Last edited:

DickCappels

Joined Aug 21, 2008
7,434
ATMEGA328 controllers with bootloaders are also available on eBay. Either method works well, but if you buy an ISP as @BobaMosfet suggests, you can program many different AVR controllers and not be stuck inside the Ardiuno bubble (you can use C and assembly language, for example).
 

DickCappels

Joined Aug 21, 2008
7,434
Are you using the Arduino development environment? Or, more directly, what software on your computer are you trying to use to use the bootloader?
 

Thread Starter

pablo.gonzalez.iei@gmail.

Joined Jun 8, 2021
5
I specify everything on the post, I'm using Arduino IDE. The bootloader works, I uploaded code and I don't have the problem with the Bluetooth anymore. But I do have problems uploading thru USB C.
I've tried choosing Arduino UNO and Arduino NANO.
All the same result:

Arduino: 1.8.13 (Windows 10), Board: "Arduino Nano, ATmega328P"

Sketch uses 924 bytes (3%) of program storage space. Maximum is 30720 bytes.

Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.


avrdude: Version 6.3-20190619

Using Port : COM6

Using Programmer : arduino

Overriding Baud Rate : 115200

avrdude: ser_drain(): read error: Incorrect function.

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_drain(): read error: Incorrect function.


the selected serial port does not exist or your board is not connected

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_drain(): read error: Incorrect function.




avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.


avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x42

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.


avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x42

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.




avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x42

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.




avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x42

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.




avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x42

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.




avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x42

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.




avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x42

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.




avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x42

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.




avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x42

avrdude: ser_send(): write error: sorry no info avail

avrdude: ser_recv(): read error: Incorrect function.




avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x42

avrdude: ser_drain(): read error: Incorrect function.



avrdude done. Thank you.
 

DickCappels

Joined Aug 21, 2008
7,434
You just went beyond my understanding of Arduino (it was a short trip). Please wait a while and see whether somebody more knowledgeable (and there are many) decides to help.
 

KeithWalker

Joined Jul 10, 2017
1,785
Have you carefully checked the connections between the ATmega328and the CH340P. interface chip? If you mis-connected the TX and RX lines on the circuit board it will never communicate. Are you sure that the TX and RX pins on the ATmega are assigned correctly in the bootloader?
 

Thread Starter

pablo.gonzalez.iei@gmail.

Joined Jun 8, 2021
5
Have you carefully checked the connections between the ATmega328and the CH340P. interface chip? If you mis-connected the TX and RX lines on the circuit board it will never communicate. Are you sure that the TX and RX pins on the ATmega are assigned correctly in the bootloader?
For the USB type C I followed the design of the BlackBoard of Sparkfun (https://www.sparkfun.com/products/16282), and yes I checked the connections are they are fine. TXD from CH340P (pin 2) is connected to RXI of atmega (pin 30) and RXD to TXO.

What d you mean with the second question? How can I assign TX and RX?
 

KeithWalker

Joined Jul 10, 2017
1,785
For the USB type C I followed the design of the BlackBoard of Sparkfun (https://www.sparkfun.com/products/16282), and yes I checked the connections are they are fine. TXD from CH340P (pin 2) is connected to RXI of atmega (pin 30) and RXD to TXO.

What d you mean with the second question? How can I assign TX and RX?
The RX and TX pin assignment will change if bluetooth software is loaded and will need to be re-assigned by re-loading the bootloader before the serial USB interface will work again.
Just as an afterthought, I assume you have the correct baud rate set on the Arduino ISP.
 

Thread Starter

pablo.gonzalez.iei@gmail.

Joined Jun 8, 2021
5
The RX and TX pin assignment will change if bluetooth software is loaded and will need to be re-assigned by re-loading the bootloader before the serial USB interface will work again.
Just as an afterthought, I assume you have the correct baud rate set on the Arduino ISP.
I'm not sure about the RX and TX assignment, you mean SoftwareSerial? I can't upload code thru USB C even without the Bluetooth module connected, with an empty code.
When burning the bootloader I use 9600 bauds, but I'm not using Arduino ISP as I'm using a Polulu ISP
 

trebla

Joined Jun 29, 2019
358
Error messages are indicating that the used USB port is wrong or the USB driver is not suitable for this chip. Try look at the CH340 TX/RX pins signals with oscilloscope or with another (known working) TTL/USB (plus another PC with serial terminal) converter when sending some characters via PC terminal program. This may isolate better your harware problem.
 

DickCappels

Joined Aug 21, 2008
7,434
If your AVR is socketed you can remove the chip, jumper the RXD and TXD pins together and then use a serial terminal to see whether the data is echoed back by the CH340.
 
Top