I'm trying to use the SPI driver to test the communication. My chip is a STM32F100RBT6B. The problem seems to be that everything I send is different from what I insert in the buffer.
For example I try to send: 0xFA 0xD1 0xB0 0xBE ; but this is what is actually sent: F5 A3 61 7D. Here is the output from the logic analyzer:
Uploaded with ImageShack.us
Here is the code I use:
Code: Select all
#define NSS 13 //PC13
#define SPI_CHANNEL SPID1 //Channel 1
static SPIConfig jn5148_spi_config_tx = {NULL, IOPORT3, NSS, SPI_CR1_BR_2 | SPI_CR1_BR_1|SPI_CR1_CPOL}; //used for transmitting and testing
static uint8_t status_padding2[4] = {0xFA,0xD1,0xB0,0xBE};
void testIP(void)
{
palSetPadMode(IOPORT3, NSS, PAL_MODE_OUTPUT_PUSHPULL);
while( TRUE )
{
spiStart(&SPI_CHANNEL, &jn5148_spi_config_tx);
spiSelect(&SPI_CHANNEL);
spiSend(&SPI_CHANNEL,4, status_padding2);
spiUnselect(&SPI_CHANNEL);
spiStop(&SPI_CHANNEL);
chThdSleepMilliseconds(2000);
}
}
/*
* Application entry point.
*/
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
testIP();
}
I use ChibiOS 2.2.6.
Can somebody explain why this is happening?