I configured the SPI as it is written in the DS:
The following code followed the initialization:
In the first iteration of the 'for' loop, the 'while' loop gets evaluated as TRUE instantly.
Also, as I could see with a scope, the clock stayed low after writing to the Transmit Data Register. Which means that the data doesn't transmitted to the peripheral device that's connected to the SPI pins.
In the second iteration of the 'for' loop, the processor gets stuck in the 'while' loop forever.
What did I do wrong?
Am I need to configure something with the PDC?
Thanks for your attention
Regards,
Dor.
- SPI enabled
- Works in Master mode
- 8 bits per transfer
- Fixed peripheral select
- PCSDEC = 0 (which means that the chip selects are directly connected to the peripheral device)
- PCS (Peripheral Chip Select) equals 7 decimal. Which means that CS number 3 is low/active.
- SCBR (baud rate) field equals 1. Which means that the SPI clock equals the Master clock (MCK).
- CSAAT (Chip Select Active After Transfer) equals 1. This configuration is required by the peripheral device.
- CPOL & NCPHA = 0 & 0 accordingly.
- RDRF (Receive Data Register Full) interrupt enabled.
The following code followed the initialization:
Rich (BB code):
for(int i=0; i<write_count; ++i)
{
while(!
(AT91C_BASE_SPI0->SPI_SR & AT91C_SPI_TDRE) // Wait for the Data Transmit Register to be empty
);
AT91C_BASE_SPI0->SPI_TDR = (char)*(data + i); // Write to the Data Transmit Register
}
Also, as I could see with a scope, the clock stayed low after writing to the Transmit Data Register. Which means that the data doesn't transmitted to the peripheral device that's connected to the SPI pins.
In the second iteration of the 'for' loop, the processor gets stuck in the 'while' loop forever.
What did I do wrong?
Am I need to configure something with the PDC?
Thanks for your attention
Regards,
Dor.