Hi, I'm trying to get the SSP controller working on an LPC11U68 with a Microchip MCP25625 CAN controller.
The problem I'm having is that when reading, I always read 0. I have checked with my scope and the correct exchange is occurring (I should read 0x98) and I can write fine. When I place it in loopback mode, I get what I put back. I added some screenshots to show my hardware settings just after the transfer. Pin 1_21 is the one I'm using as my MISO input, I've also attached a screenshot of the settings for 0-22 to show that it isn't set to for MISO.
This is my rw write code using the LPCOpen libraries:
uint8_t readWriteSpi1(uint8_t* read, uint8_t* write, uint32_t len){
xf_setup.length = len;
xf_setup.tx_data = write;
xf_setup.rx_data = read;
xf_setup.rx_cnt = xf_setup.tx_cnt = 0;
Chip_SSP_Int_FlushData(LPC_SSP1);
Chip_SSP_Int_RWFrames8Bits(LPC_SSP1, &xf_setup);
Chip_SSP_Int_Enable(LPC_SSP1);
return 0;
}
void SSP1_IRQHandler(void){
Chip_SSP_Int_Disable(LPC_SSP1);
Chip_SSP_Int_RWFrames8Bits(LPC_SSP1, &xf_setup);
if ((xf_setup.rx_cnt != xf_setup.length) || (xf_setup.tx_cnt != xf_setup.length)) {
Chip_SSP_Int_Enable(LPC_SSP1);
}
else {
transferInProgress=0;
}
}
What have I done wrong?
Hi Nicholas Hunn,
I want to be sure about some things, did you already check your slave device and be sure that is working properly? And the correct exchange you mention it's when the MCU and the CAN Controller are connected?
Both functions, the SSPWrite and the handler it seems fine, could be a configuration error before the transmition, could you share how are you configuring the SSP module?
Best Regards,
Alexis Andalon