Greetings,
I did my projects with esp8266 for some time and wanted to get familiar with 328p as well. The current setup is 328p, internal oscillator, usbtiny programmer with a linux desktop, gcc-avr, avrdude and standalone makefile. Blinking LED works. My next step is to try to read from a serial port. Here is the code I used:
#include <Arduino.h>
void setup() {
Serial.begin(9600);
while(!Serial) { delay(100); }
}
void loop()
{
while(1) {
delay(10);
Serial.println("a");
}
}
I am attaching a picture of the breadboard setup. The usb to serial is a no-brand FTDI. It is hard to see the markings on the FTDI board; tx is connected to rx on the atmega chip, and rx is connected to tx. The voltage selector on the FTDI board is set to 5V, FTDI board's power and ground are connected to the breadboard as well. TX LED is blinking on the ftdi board.
On the desktop side, here are the settings for the serial port:
stty -F /dev/ttyUSB0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
I used cu to connect to serial:
cu -s 9600 -l /dev/ttyUSB0
and the result is on the second attachment (inverse question marks).
I played with the baud rate and serial port settings, and the result is always the same.
Not sure what to look at next. Thanks.
Poor HW setup. How did you connect reset pin? It must be pulled up (Arduino uses 10k resistor to Vcc) to start MCU.
Budvar10:
Poor HW setup. How did you connect reset pin? It must be pulled up (Arduino uses 10k resistor to Vcc) to start MCU.
Thanks for pointing this out. I added a 10k pullup.
Still, getting a bunch of question marks in the terminal. It looks like the atmega is sending something -- the tx light on the ftdi board blinks (if I set the delay to 500 in the code, I can see it blinking about twice a second).
Not sure where to look now. I never used that ftdi board before, but if I connect its tx to rx, I can send characters and read them just fine.
braincat:
Thanks for pointing this out. I added a 10k pullup.
Still, getting a bunch of question marks in the terminal. It looks like the atmega is sending something -- the tx light on the ftdi board blinks (if I set the delay to 500 in the code, I can see it blinking about twice a second).
Not sure where to look now. I never used that ftdi board before, but if I connect its tx to rx, I can send characters and read them just fine.
And... reporting success. I had to reset the fuse bits on the mcu (avrdude -U lfuse:w:0xe2:m) to use 8MHz internal oscillator. I thought I've done this already, but apparently not.
Thanks.
You should also add 0.1uF caps on VCC and AVCC pins. If using analogRead(), also add a 0.1uF cap from Aref to Gnd. Do not connect Aref to 5V.
You should have a 0.1uF cap from DTR on the FTDI to Reset so that the PC software can create a Reset for software downloads is using the IDE.
CrossRoads:
You should also add 0.1uF caps on VCC and AVCC pins. If using analogRead(), also add a 0.1uF cap from Aref to Gnd. Do not connect Aref to 5V.
You should have a 0.1uF cap from DTR on the FTDI to Reset so that the PC software can create a Reset for software downloads is using the IDE.
Thank you, appreciate the suggestions.