-1

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.
  • Looks like a baudrate problem. Try either halving the baudrate on PIC or doubling the baudrate on your terminal receiver. – cup Jul 31 '22 at 07:02

1 Answers1

0

Turns out that the issue is the terminal program I was using. I swapped from the terminal program created by Microchip, "USB_Serial_Terminal_v0_02", to realterm. Realterm saved the day.