- #1
Gliese123
- 144
- 0
Homework Statement
Hi dear PhysicsForum members!
Help in this matter would mean its weight in gold..
I am trying to establish a radio link between two Atmega8 CPUs. However to be able to let these CPUs talk with each other, I have to more or less use the USART or UART as it is also called.
As far as I know, to be able to establish a radio radio link, USART is very good for such a task were the process of receiving an external serial wave has to be implemented into the CPU's register regardless of where the reading of the code may be at the moment.
SO, to do that, I have followed the datasheet as good as I can ( http://www.datasheetarchive.com/dl/Datasheets-UD3/DSAUD0046605.pdf ) and I'm aware of that I have to initialize the transmitter and the receiver by writing the following code which I eases up the issue a bit:
USART_Init:
; Set baud rate
out
UBRRH, r17
out UBRRL, r16
; Enable Receiver and Transmitterldi
r16, (1<<RXEN)|(1<<TXEN)
out UCSRB,r16
;Set frame format: 8data, 2stop bitldi
r16, (1<<URSEL)|(1<<USBS)|(3<<UCSZ0)
out UCSRC,r16
ret(I colored it so it's easier to see for you guys) :)
Obviously the upper coding works. I also wrote this which supposedly is to read and transmit data via USART:
Getchar_UART_Poll:
sbis
USR, RXC
;in
r16,UDR
;UDR turns out to be the register the bits are stored in before Transmit/Receive PutChar_UART_POLL: ;
sbis
USR, UDRE
out UDR, R16
Homework Equations
We calculated the Baud rate to be 155. Nothing essential, just to let you know that I haven't forgot it.
The Attempt at a Solution
Well, I don't know how I should proceed.. I have sought on the net for countless hours..days.. And I of course read a lot of datasheets. But it doesn't seem to work very well..
Could you please describe to me and maybe give some code examples of how I should proceed next with reading data from it and such. Please describe the obvious things as well.
Note that I am especially bad at understanding how it's working fully. I just know briefly about it as a whole.
Also be aware of that I have to write it in Assembler code with no C syntax, however if you have a very good C code laying around, it would of course be just as good.
~Thanks
Last edited by a moderator: