Hi Guys,
I completely re-wrote the code in the style that seems common on this forum and still it fails to work. I run the code with and without the monitoring software and can tell that the values that I am getting are all 0x00 becuase of the LEDs I have on my board. If anyone can find something that I am forgetting to set please let me know.
Thank you very much for your time,
drdr
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#define ce_L PTED_PTED2
#define enable_ce PTEDD_PTEDD2
void delay(int count)
{
while(count--);
}
void init_SPI(void)
{
SPI1C1 = 0x00; //in binary=01010000 to enable master SPI, disable interrupts, standard operation
SPI1C2 = 0x00; //default state for SPI control2
SPI1BR = 0x00; //default state for baud rate control
ce_L=1; //reset CE before transaction begins
enable_ce = 1;
}
byte SPI_transOne( byte val)
{
while (!SPI1S_SPTEF);
SPI1D = val; // Send byte value
while (!SPI1S_SPRF); // Wait for completion of transfer
return SPI1D;
}
void SPI_comms(void)
{
ce_L = 0; //intiate SPI transfer
(void)SPI_transOne( 0x8B); //send byte & ignore returned byte
delay(10);
PTADD = SPI_transOne( 0); //Dummy send to read a byte
delay(10);
PTBDD = SPI_transOne( 0); //Dummy send to read a byte
delay(10);
ce_L = 1; //terminate SPI transfer
}
void main(void) {
init_SPI();
SPI_comms();
for(;

{
__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */
}