Go Down

Topic: TTL (Read 1 time) previous topic - next topic

linxdev

I'm using a ATMega328-PU.  No boot loader.

Code: [Select]

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("TEST");
  delay(1000);
}


I've tried 2 TTL adapters and I'm getting this:

Code: [Select]

select(4, [0 3], NULL, NULL, NULL)      = 1 (in [3])
read(3, "\0", 1024)                     = 1
write(1, "\0", 1)                       = 1
select(4, [0 3], NULL, NULL, NULL)      = 1 (in [3])
read(3, "\0", 1024)                     = 1
write(1, "\0", 1)                       = 1
select(4, [0 3], NULL, NULL, NULL)      = 1 (in [3])
read(3, "\0", 1024)                     = 1
write(1, "\0", 1)                       = 1
select(4, [0 3], NULL, NULL, NULL)      = 1 (in [3])
read(3, "\0", 1024)                     = 1
write(1, "\0", 1)                       = 1
select(4, [0 3], NULL, NULL, NULL)      = 1 (in [3])
read(3, "\0", 1024)                     = 1
write(1, "\0", 1)   


FD 3 is the TTL adapter.

I am NOT using an external crystal. 

I've added this to my code

Code: [Select]

#ifdef F_CPU
#undef F_CPU
#endif
#define F_CPU 8000000L



On this project I need serial communications so is the 16mHz crystal required?

Chris

linxdev

I think this has to do with not having an external clock.  I have changed the fuse settings so that the chip is running at 8mHz.  At 1200bps I can read the output just fine.

Code: [Select]

cfowler@compaq-desktop:~/Dropbox/Downloads$ ./snoop  -b 1200 -s /dev/ttyUSB1
Connected to /dev/ttyUSB1.  Enter Ctrl-\,q to exit.
0x54(T)
0x45(E)
0x53(S)
0x54(T)
0x0D
0x0A
0x54(T)
0x45(E)
0x53(S)
0x54(T)
0x0D
0x0A
0x54(T)
0x45(E)
0x53(S)
0x54(T)
0x0D
0x0A



At 9600 I don't get all the output.  I only have one rock and cap set so I would like someone to confirm it IS needed before I solder it on the board.

Chris

Coding Badly

Quote
On this project I need serial communications so is the 16mHz crystal required?


Maybe.  :D  For a given temperature and voltage, the internal oscillator can be tuned to better than 1%.  Which is more than good enough for 9600 baud.

At its essence, tuning amounts to tweaking the OSCCAL register.  Atmel documents various methods of tuning (AVR053, AVR054, and AVR055).

It's a bit tedious, but tuning by hand is possible.  Keep bumping OSCCAL until it works.  Continue until it stops.  Pick a value in the middle.

This works well but you would have to add support for your processor...
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1287558192

dc42

You could also consider connecting a 3-terminal 8MHz or 16MHz ceramic resonator. These are cheaper than the crystals and don't need the caps. They are accurate to within about 0.5% which is good enough for serial comms. Google for "ZTT ceramic resonator" to find them.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Grumpy_Mike

Quote
I've added this to my code
#define F_CPU 8000000L


By the time the compiler gets to your code the damage has already been done. You need to add this line in the basic arduino stuff that gets compiled long before your code. Not too sure exactly where it is as they keep moving it but do a search and replace every instance you see of #define F_CPU 16000000L with #define F_CPU 8000000L

Go Up