I am working on my first Arduino project but I have some experience with other MCUs.
The project I am working on requires me to rewrite a driver so it can be used inside the Arduino environment.
The driver communicates over the SPI protocol but there seems to be a huge delay after the spi.transfer() function. I need to write 32-bits so I figured that I could send 4 times 8-bits.
void
AHB_WRITE_BURST_WRITE(uint32_t data)
{
/*
WAIT_FOR_TRANSMIT;
EUSCI_B_SPI_transmitData(SPI_HW_ADDR, HWREG8(&data + 3));
WAIT_FOR_TRANSMIT;
EUSCI_B_SPI_transmitData(SPI_HW_ADDR, HWREG8(&data + 2));
WAIT_FOR_TRANSMIT;
EUSCI_B_SPI_transmitData(SPI_HW_ADDR, HWREG8(&data + 1));
WAIT_FOR_TRANSMIT;
EUSCI_B_SPI_transmitData(SPI_HW_ADDR, HWREG8(&data));
*/
uint8_t Tempdata, Tempdata1, Tempdata2, Tempdata3;
Tempdata = data;
Tempdata1 = data >> 8;
Tempdata2 = data >> 16;
Tempdata3 = data >> 24;
//Send 32-bit data - spi_readwrite is defined as spi.transfer
spi_readwrite(Tempdata3);
spi_readwrite(Tempdata2);
spi_readwrite(Tempdata1);
spi_readwrite(Tempdata);
}
In the attachments, there is a picture located that shows the difference between an msp430 board(The driver was originally written by Texas Instruments so it uses driverlib) and an stm32 board which is programmed using the Arduino IDE.
The data seems to be correct but the overall transmission time takes almost 1.6ms instead of 70us.
Maybe, but not using the information you provided. Post complete code! For example, I have no clue what your spi_readwrite() does, it's not an Arduino standard function. If you implemented your WAIT_FOR_TRANSMIT, that's probably the reason for the slowness. What clockspeeds do you use on the two platforms?
Update:
Since the Arduino UNO managed to run the code without any problems i figured the problem was located in the core I used for programming my STM32.