I am trying to use the processor expert SPI bean to help establish communication between my MCU and a sensor. I know very little about how SPI works, and am having difficulty trouble-shooting the problem. Does the hcs12 store any data being sent from the slave in a buffer, which can then be read at a later time using the RecvChar command?
A potential problem is that the hcs12 only seems to run the clock (SCLK) signal while it is sending data, and I can't figure out how to get it to run during the time when it is supposed to be receiving a signal. Also, I don't see a way to modify or pick the clock speed. I have attached the document which describes the SPI interface on my sensor, and posted my code below.
/* Including used modules for compiling procedure */
/* Include shared modules, which are used for whole project */
int SPI_DELAY = 100;
int SPIcommand(byte command, byte operand)
reply = recvd1;
reply <<= 8;
reply += recvd2;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
/*** End of Processor Expert internal initialization. ***/
response = SPIcommand(4,0);
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/