Pages

hello everybody! i have a problem achiving my serial communication.
actually the biggest! it doesn't work!
i have an atmega 16 at 4mhz. i have a serial port on my desktop. and a max232.
what i want for you firstly is to tell me if there is a way to check if every part is doing its job!

- if i connect the Receive and trasmite at the serial port will it echo back?(to check that the serial and pc settings are ok)
- if i do the same on the max232 will it echo back?( to check if the max circuit is ok)

- if i connect the Receive and trasmite at the serial port will it echo back?(to check that the serial and pc settings are ok)

No, you will have to write some AVR software for that. Did you actually read the tutorial that is at the start of this thread?

Quote:

- if i do the same on the max232 will it echo back?( to check if the max circuit is ok)

No. The MAX232 is a device that deals with conversion of electrical signals levels.

Quote:

it doesn't work!

The questions you ask make it sound that you haven't really started making an attempt yet. If so, then of course it does not work. If you actually have made an attempt to code something then show that. It will help us establish where to start.

And please read the tutorial. Dean wrote it just for people in your situation - make his efforts worthwhile.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington]

i have made the connections as shown at the max232 datasheet. i have connected on the max232 the connections from the serial and from my atmega. i run the programm from the tutorial. i have tryed hyperterminal (also the private version of it) but nothing happens. no echoes.
the max232 is powered from my atmega board(homemade) with 5v. i've checked the v+ v- they output the 8,5V they shoud. i've checked the capacitor connections a thousand times. so i thought if there was a way to check every part alone.
at the hyperterminal a set the same baudrate as at the programe. i select com1 as its the only one left available ^^(at the device manager it says communications port(com1)) but nothing no echoes. any ideas?

Two tests you can do: short pins 2 and 3 of the serial cable together (disconnect it from the MAX232 first) and see if you get an echo - that will test that your PC is correctly sending and receiving data.

Next, reconnect the MAX232 but short the output TX and RX together (disconnect the AVR first). Again, see if you get an echo - that will test that the MAX232 is up and running.

If both of those work, check that you have correctly swapped over the TX and RX lines to the microcontroller, so that the PC's transmit line is connected to the AVR's receive line, and vice-versa.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

Clock source for the AVR? Internal RC or external crystal?
If the later, fuses correctly programmed?

Quote:

i run the programm from the tutorial

Which one? There are several. How can we tell which one?

The quality of the answers you get is highly correlated with the quality off the question you ask.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington]

external crystal 4Mhz fuse set to ext.crystal/resonator high freq;start up time 16k ck +64ms.
anyway there must be something with the port cause if i cross pin2-3 there is no echo also so i'll check it and if the problem persists i'll come back seeking for your knowledge guys! thanks a lot! now some time off and happy holidays to you all!

anyway there must be something with the port cause if i cross pin2-3 there is no echo also

There are several other possible reasons. Some might be revealed by the other tests that Dean suggested (apart from crossing the cables). Do those.

And show your actual code - we still do not know what you are running.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington]

Hello,
Iâ€™ve read through the tutorial several times, and through allâ€¦ 23 pages of this particular thread!

This question seems to have been posted 3-4 times already on this forum over the past few years, but has yet to have been addressedâ€¦

Iâ€™m using the same sample code as provided in the tutorial. The Mega1280 is able to transmit characters perfectly fine: I can even transmit through a long stream of characters. But the Mega1280 Receive does not seem to be working. Here is my setup:

PC(XP) USB to RS323 (Vantec), then SparkFun adapter (instead of MAX232), then the Mega1280.
Both PC and Mega1280 are set to 9600 baud, 8-bits, no parity, 1 stop bit, and no Flow Control.
System is already using a previously used external 16MHz clock.
When pin 2 and 3 of the COM port are shorted, the loop-back works fine.
Iâ€™ve tried both HyperTerminal and PuTTy: both respond the same way.
Used the Ocilloscope: Tx and Rx pins on the Mega1280. Both have signal movement, and look reasonably valid.
The Tx and Rx signals are correctly crossed over between the Mega1280 and SparkFun.

Iâ€™ve tried to mess with the Emulation mode (ANSI, TTY, VT100, etc.) and havenâ€™t gotten any different results

Most people would use a terminal program. Until recently all copies of Windows had Hyperterminal but these days (thank God) they've dropped it so you have to choose one for yourself. There's been many threads of recommendations here but start with Brays, Realterm, TeraTermPro and see how you get on.

i have got a bit of a problem with serial communication, my atmega16 sends a totally different value from its tx then the one I am expecting it to give when I send data above decimal 127, any suggestions?

i have got a bit of a problem with serial communication, my atmega16 sends a totally different value from its tx then the one I am expecting it to give when I send data above decimal 127, any suggestions

This is known as "Code Pages". Different devices map different characters into positions 127..255

i have got a bit of a problem with serial communication, my atmega16 sends a totally different value from its tx then the one I am expecting it to give when I send data above decimal 127, any suggestions?

Yes.
The first suggestion is: Tell us what data you think you are sending, and tell us what data you see "at the other end".
The second suggestion is: Show us the code. Preferrably a minimal program with everything thrown out except the UART send and receive parts, perhaps also the code that you actually use to see what gets sent or what is received (e.g. the code to display data on an LCD, if that is what you are doing. It is probably not of interest to see the ADC code as such. So perhaps do something like this on the sending side (sketchy):

unsigned char c = 0;
do {
UART_send(c);
c++;
} until (c == 255);

Cliff! I read the post as he is sending binary data (readings from the ADC from one AVR to another). No Windoze involved, ergo no code pages.

I'd speculate that it is

- either a signed/unsigned problem

- or a problem with how the binary data is ultimately converted into readable form, e.g. to a string to show on a display

- or perhaps even a problem with setting up the ADC and/or take the reaadings from it (8 bit or 10 bit? left or right adjusted result?...)

So we really need more info on what goes wrong, and we really need to see some code..

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington]

Thanks a lot for the replies...!
I am sending values like 220 from my avr's serial port, I know my serial port works correctly because it sends ascii letters and numbers correctly. I am using a terminal program on my PC to troubleshoot the MC before connecting it to my other MC.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington]

Were you logged in when you tried? You can only download attachments when logged in. If it still doesn't work what's actually happening? If it happens to be downloading the file with the name "index.php" then after download just rename that to "uart.pdf" and it should work.

Just tested it, and it works fine for me. Do you get any error message, or is the download corrupt, or what...?

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington]

I'm new with AVR and the STK600.
The tutorial is awesome (great job Dean).
I tried the Code, but it's not possible to receive or send data.

I'm using the STK600 with an ATMega1280 and the AVRStudio (Version 4.18).
If I connect the Board via USB to my PC, I can adjust VTarget (5V), Clock Generator (8MHz) and the fuses.
After that I switch everything to the JTAGICEmkII. In the HW Settings the VTarget is still 5V but the Clock Generator is now blank. So what is my Clock now?
I guessed it's still 8MHz, so I choose for F_CPU 8MHz (CKDIV8 fuse non-selected).
Terminal works, because if I short the RX/TX pins of the RS232 Spare, I get an answer.

Here's my code, maybe there is a mistake in there..

#include
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (( 8000000 / (USART_BAUDRATE * 16UL)) -1)
int main (void)
{
char ReceivedByte;
UCSR0B = (1<<RXEN0) | (1<<TXEN0); //Turn on the transmission and reception circuitry
UCSR0C = (1<<UCSZ00) | (1<<UCSZ01); //Use 8-bit character sizes - URSEL bit set to select the UCRSC register
UBRR0L = BAUD_PRESCALE; //Load lower 8-bits of the baud rate value into the low byte of the UBRR register
UBRR0H = (BAUD_PRESCALE >> 8); //Load upper 8-bits of the baud rate value into the high byte of the UBRR register
for (;;) //Loop forever
{
while ((UCSR0A & (1 << RXC0)) == 0 )
{}; //Do nothing until data have been received and is ready to be read from UDR
ReceivedByte = UDR0; //Fetch the received byte value into the variable "ByteReceived"
while ((UCSR0A & (1 <<UDRE0)) ==0 )
{}; //Do nothing until UDR is ready for more data to be written to it
UDR0 = ReceivedByte; //Echo back the received byte back to the computer
}
return 0;
}

I connected the RX/TX pins of the RS232 Spare to PE0 and PE1.
The switch for the different types of clock is set to ext, as I use the programmable clock generator (I guess...)

Okay, problem solved, but I don't know why...
I tried to switch the LED's in the upper code on like:

DDRB = 0xFF;
PORTB = 0xF0;

but it didn't work. So I tried to toggle the LED's without uart and it worked.
After that I copied line for line of the upper code in the working code and tried after each line if the LED's are still working.
At the end everything works!!

We really shouldn't be using this tutorial thread for general fault diagnosis but you are aware, are you not, that the STK500 and STK600 LEDs use inverse logic so 0=lit and 1=off?

Anyway the question is rhetorical as I'm now going to lock this thread. If anyone has genuine feedback to improve the article in the first post then contact js, plons or clawson and ask one of us to temporarily unlock this thread so you can add your feedback. (one of us may then be able to edit the original article).

Hi all, good night.
I a new with attiny2313 works. IÂ´m trying to setup a PC to attiny communication in a way that if I issue the command LED1 the led on PORTD6 will light on. So far IÂ´m learning how to use seral communication and I took an example code and modified a little bit by indroducing a if/else condition. The strange thing that IÂ´m not undestanding is:
1) If I send 'S' (=83) the led turns on after the third time that the caracter is sent.
2) If I send an A, I have to send it 3 times befor I get back the letter B ( the code adds 1 to the letter sent).
Cand someone explain that to me? IÂ´m posting the code here and I do not have any issue with fuses. It is working but with a strange behaviour.
[code]/*
* serialcom3.c
*
* Created: 11/04/2012 20:39:57
* Author: Alf
*/

/* --------------------------------------------------------------
Main - program that recieves a character then transmits back the next character.
An example would be if you send in an A, the chip will return a B
---------------------------------------------------------------- */
int
main (void)
{
DDRD |= _BV(1) | _BV(6);