time from SPI TXEMPTY to RDRF?

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

hi,

I can't find any info about this time (or number of MCK clocks) between TXEMPTY flag set to RDRF flag set on UC3B's datasheet.

I need to know this because if the previous received data in RDR is not read out, then I think RDRF will be kept at set, so if then send out another byte and wait for the new received byte to replace the old data in RDR, then I guess the spi_read() function I used, could end up return me the previous data in RDR, not the new one (this is of course if the time between TXEMPTY to RDRF is quite long).

Anyone knows?

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

What about using an "blind" read before sending, then do the "real" read. You cannot read it too many times :)

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

well, yes, that's ok, but I want to know this timing first.

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

You should email atmel support about that.

Anyway, here is example of C procedure I use for UC3 slave:

unsigned int local_spi16(volatile avr32_spi_t *spi, unsigned short outdata) {
   unsigned short temp11;
   temp11 = spi->rdr >> AVR32_SPI_RDR_RD_OFFSET; // Clear RDRF 
   spi->tdr = outdata << AVR32_SPI_TDR_TD_OFFSET;
   gpio_port_pa->ovrs  = 1 << (AVR32_PIN_PA09 & 0x1F); // Attend master
   while ((spi->sr & AVR32_SPI_SR_RDRF_MASK) != AVR32_SPI_SR_RDRF_MASK);
   gpio_port_pa->ovrc  = 1 << (AVR32_PIN_PA09 & 0x1F);		// Confirm to master
   temp11 = spi->rdr >> AVR32_SPI_RDR_RD_OFFSET;
   return temp11;
}

SPI is difficult if the slave is not responding instantly at all times. The above example use a separate IO pin to acknowledge the SPI master.

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

ok, thanks, i will send them email.