I am receiving strange results on my pic32 and I am not clear what have I did wrong.
Using a logic analyzer I have confirmed that the slave is replying with 0xA3. I also did a test with an LED to see if "test == 0xA3"
and the result was true.
ut when I run this code I get 0x3F in my serial terminal (configured to display as hex):
csLow();
spiWrite(0xFF);
csHigh();
Delayms(10);
char test = SPI1BUF;
U1TXREG = test;
//sprintf(str, "%X", test);
//UART1_Tx(str);
However when I convert the int to a string using sprintf and transfer to the UART buffer it prints "A3" which is what I would expect.
I also tried this:
U1TXREG = test & 0xFF;
Delayms(1);
U1TXREG = (test >> 4) & 0xFF;
Delayms(1);
U1TXREG = (test << 4) & 0xFF;
The output is "3F 0A 30"
I also tried:
U1TXREG = 0xA3;
U1TXREG = 0xA0;
U1TXREG = 0x03;
U1TXREG = 0xFF;
My terminal displays:
3F 3F 03 3F.