Serial ADC---Interface with AT90USB1287 in USART SPI mode

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey...everyone I am interfacing serial ADC.
I need some help , regarding USART in SPI mode, http://www.mouser.com/ds/2/256/M... ... 102916.pdf
It requires 24 continuous clock pulses for one conversion, however I can only get continuos 16 clock pulses by giving one control byte and padding 8 0's. I tried to give padding 16 0's but clock stops after 16 clock pulses. I don't know how to get 24 continuos clock at XCK pin for conversion to complete?

If you see figure 2 in page 11 of the datasheet, adc is required to have 1 control byte before conversion take place , and after that 16 clock pulses gives adc data...I am transmitting control byte followed by two 0 valued bytes, but I only see control byte and one zero byte at Tx pin and clock on XCK pin runs for 16 clock pulses only...how I can extend it to have 24 pulses...
Thanks.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I doubt if the SPI chip minds if there is a short gap between each SPI byte. e.g.

     spi(CMD);
     hi = spi(0);  //read 16-bit reply
     lo = spi(0);

When you use the regular SPI, you always get gaps.
If you use USART_SPI, you can get continuous clocks because the USART has a transmit buffer. e.g.

     while ((UCSRA & (1<<UDRE)) == 0);  //? TX free
     UDR = (CMD);
     while ((UCSRA & (1<<UDRE)) == 0);  //? TX free
     UDR = 0;      //dummy
     while ((UCSRA & (1<<RXD)) == 0);   //? RX avail
     dummy = UDR;  //reply from CMD
     while ((UCSRA & (1<<UDRE)) == 0);  //? TX free
     UDR = 0;      //dummy
     while ((UCSRA & (1<<RXD)) == 0);
     hi = UDR;  //reply from first 0
     while ((UCSRA & (1<<RXD)) == 0);
     lo = UDR;  //reply from second 0

In practice, you will get perfect clock train.
I have put the sequence in long-hand. You would actually use a neat function call.

Untested. I have not read your PDF.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks David, I will try this...and let you know.