Dear Mr, I have problem with SPI interface on SAM9G45. Osciloscope is connected to MOSI, SCK, CS wire. I set SPI interface to 8bit mode, master mode. If I send 8bit word to TDR(transmit data register), I see on scope always previous 8bit word. I try to write this problem on example: 1. while ((*AT91C_SPI0_SR & AT91C_SPI_TXEMPTY) == 0){}; 2. *AT91C_SPI0_TDR=0xF1; 3. while ((*AT91C_SPI0_SR & AT91C_SPI_TXEMPTY) == 0){}; 4. *AT91C_SPI0_TDR=0x01; At note 1. im waiting for clear transmit buffer At note 2. im transmiting number 0xF1 At note 3. im waiting for clear transmit buffer At note 4. im transmiting number 0x01. I see on my osciloscope that number is not 0x01 but 0xF1!!! Transmit function, as I know from Atmega chips and AVR32 chips, would transmit 0x01. I think setting of SPI interface is good. But where is the problem? All setting code is here: void spi_init(void) { uint32_t baudrate; *AT91C_PMC_PCER= SPI0_PERIPH_ID; //clock for spi0 enabled *AT91C_SPI0_CR=AT91C_SPI_SPIDIS; *AT91C_SPI0_CR=AT91C_SPI_SWRST; //reset *AT91C_SPI0_CR=AT91C_SPI_SWRST; //reset *AT91C_SPI0_MR=AT91C_SPI_MSTR | AT91C_SPI_MODFDIS;//master mode, disable fault detection baudrate = BOARD_MCK/1000000;//1Mbit *AT91C_SPI0_CSR=AT91C_SPI_BITS_8 | AT91C_SPI_CPOL | AT91C_SPI_NCPHA | ((baudrate&0xFF)<<8) |AT91C_SPI_DLYBS;//| AT91C_SPI_CSAAT; //AT91C_SPI0_SR //AT91C_SPI0_RDR *AT91C_SPI0_CR=AT91C_SPI_SPIEN; } Thank you, RB
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.