Tool/software: Code Composer Studio
hi,
I need help with my write functions for SSI.
I was able to read but then I couldn't write over my spi.
and i don't know what im doing wrong.
below is my read and write function.
void ft_Wr8(unsigned long ftAddress, unsigned char ftData8)
{
unsigned char cTempAddr[3]; // FT800 Memory Address
cTempAddr[2] = (char) (ftAddress >> 16) | MEM_WRITE; // Compose the command and address to send
cTempAddr[1] = (char) (ftAddress >> 8); // middle byte
cTempAddr[0] = (char) (ftAddress); // low byte
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_CS, 0); // Set chip select low
while (SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx) != 0)
;
SSIDataPut(SSI0_BASE, &cTempAddr[2]); // Send Memory Write plus high address byte
SSIDataPut(SSI0_BASE, &cTempAddr[1]);
SSIDataPut(SSI0_BASE, &cTempAddr[0]);
SSIDataPut(SSI0_BASE, &ftData8); // Send data byte
while (SSIBusy(SSI0_BASE))
;
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_CS, GPIO_PIN_CS); // Set chip select high
}
unsigned char ft_Rd8(unsigned long ftAddress)
{
unsigned char ftData8; // Place-holder for 8-bits being read
unsigned char cTempAddr[3]; // FT800 Memory Address
unsigned char cZeroFill = ZERO;
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_CS, 0); // Set chip select low
while (SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx))
;
cTempAddr[2] = (char) (ftAddress >> 16) | MEM_READ; // Compose the command and address to send
cTempAddr[1] = (char) (ftAddress >> 8); // middle byte
cTempAddr[0] = (char) (ftAddress); // low byte
SSIDataPut(SSI0_BASE, cTempAddr[2]); // Send Memory Write plus high address byte
SSIDataPut(SSI0_BASE, cTempAddr[1]);
SSIDataPut(SSI0_BASE, cTempAddr[0]);
// SSIAdvDataPutFrameEnd(SSI0_BASE, cZeroFill); // Send dummy byte
SSIAdvDataPutFrameEnd(SSI0_BASE, cZeroFill); // Send dummy byte
SSIDataGet(SSI0_BASE, &ftData8); // Receive data byte
while (SSIBusy(SSI0_BASE))
;
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_CS, GPIO_PIN_CS); // Set chip select high
return ftData8; // Return 8-bits