Forum: ARM programming with GCC/GNU tools ATMega324P and ATA5811 problem

Author: Chris Huang (rentien)
Posted on:

Rate this post
0 useful
not useful
So i'm trying to get my atmega324p (both atmel parts) and ata5811
transceiver to work and begin trasmission for my school project. I can't
seem to get the two to work... i was wondering if anyone could give me
any insight as to whats wrong with my setup or code.

Basically i have wired over the ATA5811 via SPI to the
Microcontroller... and i have PORTA going to 8 LED's to display over to
me what... numbers are being passed around so... here is my code.

void SPI_init(void){

  DDRB = ((1<<DDB4)|(1<<DDB5)|(0<<DDB6)|(1<<DDB7)); //spi pins on port b
MOSI,SCK,SS outputs, MISO input
  SPCR =
((1<<SPE)|(1<<MSTR)/*|(1<<SPR0)*/|(1<<CPOL)|(1<<CPHA)|(0<<DORD));  //
SPI enable, Master, f/16


char SPI_Transmit(char cData){

   SPDR = cData;
   while(!(SPSR & (1<<SPIF)))
   return SPDR;

void main()
DDRA=0xFF;     //All A port pins as output
DDRC=0xFF;    //All C port pins as output




  for (n=1; n<5; n++)
and i didn't finish the closed brackets.

anyways the problem is... no matter what i put for the SPI_Transmit
command 2 commands before a = SPDR, i just get an echo of the command
out on the LEDs... so in this case, i get 72... so... and the data sheet
says if i send a read command of a control register i should get back
the... settings on that register... which isn't the same as the command
i sent to read it. (for write commands however, you are supposed to just
get echoes of your commands so you can verify that your command made it
to the ata5811 i guess)

so my question is why can't i get the read command to send me the
settings on the registers instead of... just an echo of the read command
i sent in... which is useless to me. Thanks in advance for you guys'



Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.