Page 1 of 2

Clock setting Help!!

Posted: Tue Mar 04, 2025 8:04 am
by seokgi
Hello?
I am working on a project with PIC33EP256MC202.
I want to do serial communication at 19200 baud.
However, it does not work properly.
I set it to 19200 in FC10, but it appears normally at 2400 baud.
It seems that the oscillator setting is wrong.
I will upload the operating status.
Please help me set it up.
Thank you.

Re: Clock setting Help!!

Posted: Tue Mar 04, 2025 8:07 am
by seokgi
Here my project

Re: Clock setting Help!!

Posted: Tue Mar 04, 2025 11:41 am
by medelec35
Hello.
What osc speed are you after?
I have added c code to hopefully set the osc speed to 16MHz as that is what your program options show.
The internal osc Speed can be upto 64 MHz, so I would recommend being set to higher than 16MHz.

Can you let me know if not working 16MHz ,then I will look into this further.

Re: Clock setting Help!!

Posted: Tue Mar 04, 2025 3:09 pm
by seokgi
Thanks for your help.
I haven't tested it yet.
I'll test it tomorrow when I get to work.
I want to run it at the maximum speed this MCU can handle, or 64MHz.
Thanks for helping me set it up.

Re: Clock setting Help!!

Posted: Tue Mar 04, 2025 3:24 pm
by medelec35
Hi.
You're welcome.
Hopefully, attached will run at 64MHz.
I have never used dspic devices so fingers crossed it will work.

Re: Clock setting Help!!

Posted: Wed Mar 05, 2025 4:09 am
by seokgi
I ran the project by setting it as you helped me.
However, it doesn't run properly.

If I select 64mhz in C Code, I should select 8mhz in the settings.
Serial communication works normally, but 2400Baud and 38400baud or higher don't work. MCU works very slowly.

Do I need to change other settings? Please tell me how.
Thank you.

Re: Clock setting Help!!

Posted: Wed Mar 05, 2025 8:27 am
by stefan.erni
Hi seokgi , Hi Martin

It is also possible to change the BRG register without the clock. The number 216 works for me for 115200.
You can calculate this for your configuration or try it out. For very slow baud rates you should also look at bit3 in the U2MODE register

Insert after Monitor init:
2025-03-05_09-17-49.PNG
2025-03-05_09-17-49.PNG (136.13 KiB) Viewed 1454 times
Program:
250304-V002_3.fcfx
(34.19 KiB) Downloaded 18 times
From the data pdf PIC:
2025-03-05_09-07-50.PNG
2025-03-05_09-07-50.PNG (94.84 KiB) Viewed 1454 times
2025-03-05_09-09-38.PNG
2025-03-05_09-09-38.PNG (195.69 KiB) Viewed 1454 times

Re: Clock setting Help!!

Posted: Wed Mar 05, 2025 8:48 am
by medelec35
Thanks Stefan.
Hi seokgi
It would be good to know at what clock speed hardware is running at.
The easiest way is to run a 1 sec flash test and measure the time duration the LED is on for, or you can use a scope or a logic analyser.

Then we can see if its an issue with the clock frequency or the UART component.

If it's the clock frequency it can be revisited.

Re: Clock setting Help!!

Posted: Wed Mar 05, 2025 8:53 am
by seokgi
I want the mcu to run at 64MHz.

But with the above settings it only runs at 8mhz.

Thanks

Re: Clock setting Help!!

Posted: Wed Mar 05, 2025 5:18 pm
by medelec35
Sorry, I spotted an issue.
Can you try with the attached.