Other Parts Discussed in Thread: AM3359
Hi, I'm using the ICE V2 SPI1 port and am having trouble getting the SPI1_CS0 (pin C12) line to work correctly. I can toggle the output when it's configured as a GPIO so I know I'm on the right pin. I can send data and see the clock and data lines working correctly, just the CS0 pin never changes state.
PLEASE DO NOT MOVE THIS POST TO STARTERWARE!!! NO ONE RESPONDS IN THAT FORUM!!
I have 2 questions:
1) When configured as a master using the following code, I can't force the CS0 pin using the assert/de-assert routines or writing directly to SPIEN0 with SPIENDIR=0. The called McSPI routines are the as supplied IDK/starterware in osdrv_mcspi and mcspi.c
void SPI1_Init()
{
int b;
int pin=17; //GPIO3_17 is CS0
int spiId=1; //for base address SP0 or SPI1
chNum=1; // same as spiId?
unsigned char spiClockDiv=20;
unsigned char spiDir= 0;
b=McSPIPinMuxConfig(spiId);
b=McSPIInit(spiId, spiClockDiv, spiDir, MCSPI_MULTI_CH,chNum);
McSPIWordLengthSet(baseAdd,MCSPI_WORD_LENGTH(16),chNum);
McSPICSPolarityConfig(baseAdd,MCSPI_CS_POL_LOW,chNum);
McSPIChannelEnable(baseAdd,chNum);
/* SPI1 CS0 manual control*/
HWREG(baseAdd + MCSPI_SYST) = (HWREG(baseAdd + MCSPI_SYST) & ~MCSPI_SYST_SPIEN_0);
HWREG(baseAdd + MCSPI_SYST) |= (1 << MCSPI_SYST_SPIEN_0_SHIFT); //one of these SHOULD change CS0
McSPICSAssert(baseAdd,chNum);
McSPICSDeAssert(baseAdd,chNum); //NONE of these lines affect the state of CS0
}
2) How can I configure the CS0 pin to work automatically so the code doesn't have to monitor the transmission then de-assert it after the buffer is sent?