samrajaf / pinguino32

Automatically exported from code.google.com/p/pinguino32
0 stars 1 forks source link

DCF77 library does not account of 40Mhz clock speed of GENERIC32MX250F128 and GENERIC32MX220F032 #39

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. compile and flash the the DCF77 example sketch. 
2. run it. Observe the CDC serial output for some minutes in a terminal.
3. One will see that time is not getting in sync. 

What is the expected output? What do you see instead?
Time should get in sync after at least 3 min if reception is ok. 

What version of the product are you using? On what operating system?
X.4 r713. 

Please provide any additional information below.

I had a look into dcf77.c and found that it does not handle different cpu 
clocks / 40Mhz instead of 80Mhz. 

For debugging purpose I patched dcf77.c in DCF77_start(u8 dcfPin)
at lines 280 - 284. As follows: 

    #if defined(PIC32_PINGUINO_220)||defined(GENERIC32MX250F128)||defined(GENERIC32MX220F032)
    PR1      = 6250;                    // load period register
    #else
    PR1      = 12500;                 // load period register
    #endif

This solved the issue for me. I tested that on my DIY board with a 32MX220F032.

I'm not sure if this is the best way to fix it. Maybe there is a way to query 
the clock speed and then do the math for the pre load register value.
Instead of having that hard coded.

Original issue reported on code.google.com by gerrit.b...@gmail.com on 24 Feb 2013 at 4:05

GoogleCodeExporter commented 8 years ago
Fixed in rev.770

Original comment by rblanchot@gmail.com on 23 Apr 2013 at 7:21