UART baudrate wrong
Posted: 24 May 2022 20:55
Hi,
I am currently working on a UART terminal for a dsPIC33EP512MC502. UART1 should be on Pin 21 and 22 of a 28pin DIP package. Code looks like this:
void main () {
Unlock_IOLOCK();
PPS_Mapping_NoLock(42, _OUTPUT, _U1TX); --> Pin 21 --> RP42
PPS_Mapping_NoLock(43, _INPUT, _U1RX); --> Pin 22 --> RP43
Lock_IOLOCK();
UART1_Init(9600);
Delay_ms(1000);
UART1_Write_Text("Start");
}
The terminal should display "Start", but the are only some undefined signs displayed. This is a typical phenomenon for wrong baudrate, so I think that the project settings could be wrong or that clock could be wrong. I wanted to run the dsPIC with 50 MHz. Is there anything to care about in main () or is it enough to write 50 MHz in the frequency field of the project settings? See project settings attached. Do I have to make some configuration for PLL? Is there anything else missing in the code?
Thank you.
Best regards
I am currently working on a UART terminal for a dsPIC33EP512MC502. UART1 should be on Pin 21 and 22 of a 28pin DIP package. Code looks like this:
void main () {
Unlock_IOLOCK();
PPS_Mapping_NoLock(42, _OUTPUT, _U1TX); --> Pin 21 --> RP42
PPS_Mapping_NoLock(43, _INPUT, _U1RX); --> Pin 22 --> RP43
Lock_IOLOCK();
UART1_Init(9600);
Delay_ms(1000);
UART1_Write_Text("Start");
}
The terminal should display "Start", but the are only some undefined signs displayed. This is a typical phenomenon for wrong baudrate, so I think that the project settings could be wrong or that clock could be wrong. I wanted to run the dsPIC with 50 MHz. Is there anything to care about in main () or is it enough to write 50 MHz in the frequency field of the project settings? See project settings attached. Do I have to make some configuration for PLL? Is there anything else missing in the code?
Thank you.
Best regards