I currently have the problem that when I want to send a byte via the SPI interface, it gets stuck in the first while loop.
just why?
What other condition must exist?
Code: Untitled.c Select all
void spiWriteByte(uint8_t data)
{
int timeout = 0;
//spi->dev->mosi_dlen.usr_mosi_dbitlen = 7;
REG_WRITE( SPI_MS_DLEN_REG, 7 );
//spi->dev->data_buf[0] = data;
REG_WRITE( SPI_Wn_REG(0), data );
//spi->dev->cmd.update = 1;
REG_SET_BIT( SPI_CMD_REG, SPI_UPDATE_bm );
//while (spi->dev->cmd.update);
while ( REG_READ( SPI_CMD_REG ) & SPI_UPDATE_bm )
{
delay(100);
}
//spi->dev->cmd.usr = 1;
REG_SET_BIT( SPI_CMD_REG, SPI_USR_bm );
while ( REG_READ( SPI_CMD_REG ) & SPI_USR_bm )
{
delay(100);
}
}