SAM4s USART SPI Mode

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

PeteSCH
Posts: 5
Joined: Wed Jul 01, 2015 3:14 pm

SAM4s USART SPI Mode

Wed Jul 01, 2015 3:16 pm

Hi,

i am facing a problem regarding the USART SPI interface.

I am using an SPI Flash an the SAM4s controller.

The function is supposed to read out the manufacturer ID of the SPI Flash.

Here the short code:



void test_spi_flash(void)
{
uint8_t tx_data[SPI_BUFFER_SIZE] = {0x9f};

uint8_t rx_data [SPI_BUFFER_SIZE];
uint8_t manufacturer_id = 0;

usart_spi_force_chip_select(SPI_PORT); //sets CS to 0
usart_spi_write_packet(SPI_PORT, tx_data, 1);

usart_spi_read_packet(SPI_PORT, &rx_data, 3);

printf("Manufacturer ID: %x\r\n", rx_data[0]);

usart_spi_release_chip_select(SPI_PORT); //sets CS to 1

}



The strange thing is, that when read and write are enabled i only get the 1 clock cycle for the writing process. If i //comment the write_packet line i get the 3 clock cycles for 3 Bytes reading.

Both Reveiver and Transmitter are enabled before. Does someone where the problem is? Why is only the writing process considered when both enabled?

Thanks in advance.

BEst regards

Patrick

Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest