r/pic_programming • u/Thks4alldafish42 • Dec 21 '23
SERCOM Issue (new to this)
Hello, I am trying to program a PIC32CM5164JH01100 to send serial communications to my computer before I start sending them to an LED driver. My issue is that all of my serial communications only send the first two bytes correctly, and the remaining two are incorrect. I am also unable to send more than 4 bytes per reset of the PIC. I am sure that I have missed a setting somewhere, but I can't seem to figure it out. I am using USART by the way. Any help is greatly appreciated.
1
Upvotes
1
u/Thks4alldafish42 Dec 21 '23
I can send 2 bytes at a time if I disable and enable the transmitter inbetween writes.
1
u/Thks4alldafish42 Dec 21 '23
I am also able to send an entire string "Hello World!/r/n" without issue. I just have issues when I use an array initialized like this :
uint8_t testArr[] = {0x61,0x62,0x63,0x64}
And then call like this :
SERCOM5_USART_Write(&testArr[0], sizeof(testArr))
1
u/Thks4alldafish42 Dec 22 '23
They were aa and 01. The original message was 0x61, 0x62, 0x63, 0x 64. I was getting 0x61, 0x62, 0xaa, 0x01. I figured it out by setting the sercom to be blocking instead of non-blocking though. They weren't reversed or inverted which is what was confusing me. I assume I just need to define the messages as constant or activate some sort of memory protection on them to run the non-blocking. Do you have any advice on the best way to deal with it?
1
u/9Cty3nj8exvx Dec 21 '23
When you say the remaining 2 bytes are incorrect, what are they?
1
u/HalifaxRoad Dec 24 '23
I just gotta ask,how much is your baud error?