Page 1 of 1

RTC component and dsPIC33FJ128GP802

Posted: Tue Dec 19, 2017 11:02 am
by viki2000
Hi,
I have FC7 Professional updated to the latest version 7.3.0.5 (19.12.2017).
The RTC component is version 2.0.
I use dsPIC33FJ128GP802 with internal oscillator (FRC) + PLL for CPU and an external crystal 32.768Khz attached to the SOSC pins for RTCC.
Below is a test program, which does not work for me.
The data and time is set as I want, but seems there are no clock, nothing changes.
I look at the data on PC with a serial monitor software using UART of the PIC and a TTL-USB converter.
Do I need to make more RTC register settings in a C code? If yes, what exactly?
I expected that all the necessary settings to take place automatically in Initialization Macro, but it seems not.
Could you please help to debug and find the problem?

P.S. Using the same hardware and code written with the CCS C compiler, everything works fine, and then we may assume there is a (missing) setting problem in Flowcode. Below is the C code used with CCS.
dsPIC33FJ128GP802_UART.fcfx
FC7 RTC - non working code
(13.92 KiB) Downloaded 330 times
dsPIC33FJ128GP802_32768_crystal.c
CCS C compiler - working code
(2.58 KiB) Downloaded 326 times

Re: RTC component and dsPIC33FJ128GP802

Posted: Tue Dec 19, 2017 1:42 pm
by viki2000
The next C code placed instead of Initialize or before or after Initialize makes the RTC to run.

Code: Select all

/* Enable the secondary oscillator for 32.768KHz crystal */
__builtin_write_OSCCONL(OSCCON |2);

/* enable write to the RTCC */
__builtin_write_RTCWEN();
_RTCEN = 1;             /* enable the RTCC module */

_RTCPTR = 0b11;         /* set the RTCC Value register window to Year */
RTCVAL  = 0x0017;       /* set year to xx17 */
RTCVAL  = 0x1219;       /* set Month = 12, Day = 19 */
RTCVAL  = 0x0313;       /* set Weekday = 3, Hour = 13 */
RTCVAL  = 0x3400;       /* set Minutes = 34, Seconds = 00 */

_RTCWREN = 0;           /* lock the RTCC, no more writes */
Unfortunately it jumps 7s - this is what I see on PC screen to each UART TX, which is not normal, beacus ein reality is max. 1s and something, under 2s.
Further debugging assistance is welcome.

Do I still need to apply the patches from here "Flowcode_7_Latest_240817.zip":
viewtopic.php?f=63&t=18760&p=83423&hilit=RTC#p83423
or is it enough that I downloaded and applied "Patch7.3.0.5.exe"?

Re: RTC component and dsPIC33FJ128GP802

Posted: Tue Dec 19, 2017 2:07 pm
by LeighM
the patches from "Flowcode_7_Latest_240817.zip" will be older than the latest version 7.3.0.5 release