For anyone interested, I figured out what my issue was, though I don't understand why part of it is necessary and I hope someone knows a way around it.
One uncontroversial error that I had was forgetting to take the modem out of reset. After adding the following I was able to read/write using the BDM's step-by-step mode.
PTDDD_PTDDD3 = 1;
PTDD_PTDD3 = 1;
However not until I put a considerable (and somewhat debilitating) delay into my master to slave transfer function that it worked as stand-alone.
void delay(int count)
{
while(count--);
}
byte SPI_transOne( byte val)
{
while (!SPI1S_SPTEF);
delay(255); //very important delay...for some reason
SPI1D = val; // Send byte value
while (!SPI1S_SPRF); // Wait for completion of transfer
return SPI1D;
}
If anyone can tell me why I need a delay after my check I would greatly appreciate it.
Thank you,
drdr
Hello drdr,
This delay is not required for the SPI to operate.
The slave device may require some "processing time" after a certain amount of bytes are sent or a complete command is sent.
More than likely the delay is only required sometimes and not at every transfer.
Hi Peg,
Shouldn't these checks have taken care of that?
while (!SPI1S_SPTEF);
while (!SPI1S_SPRF);
Otherwise how can I tell when it needs the delay and when it doesn't?
Thanks,
drdr
Hi drdr,
As I said the actual SPI bit will work without delays. At the slave end the bytes must be unloaded out of the SPI register by the code running there. Normally this will be done quite quickly and transparently but once, say, a whole command is sent it may need time to gather the response and write it to the SCI in order to send it back. This quite often takes additinal time that must be allowed for in the master code.
Hi Peg,
The only operations I performed was to set GPIO_Dir and GPIO_Data_Out in the modem, so I don't see why any of that would take very long since I'm not expecting a response from the slave. Either way, how can any logic to the master code work without some sort of feedback from the slave? Unless there is a predictable table of the maximum times it takes to do certain operations, the master can never know for sure if it's okay to continue if there is no feedback.
Thanks for your help,
drdr
Hi Peg,
You were right about the delay not being necessary for every SPI access. In fact, my problem was the lack of a 25ms wait needed after the modem's reset (which I formerly performed right before the access). I hope not to come across any modem operation that requires more time as it seems extremely difficult to take such an event into account.
Thanks and Regards,
drdr