<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Brian,<div><br></div><div>Thanks for this. I've updated the source code with your comments, for historical record. With this confirmed, I think we should be good to go. I'll do some further testing over the next few nights (perhaps turning off the GSM sync and seeing how badly/well it drifts).</div><div><br></div><div>Regarding the clock speed, I think it is fast enough now (as other than the CAN handling, there is little else going on), and presumably we gain a small power advantage from running at FOSC=20MHz (vs 40MHz).</div><div><br></div><div>Regards, Mark.</div><div><br><div><div>On 23 Oct, 2014, at 1:00 pm, HONDA S-2000 <<a href="mailto:s2000@audiobanshee.com">s2000@audiobanshee.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi guys,</div><div><br></div><div>I just started looking at the OVMS again after a long time away, so forgive me if I get some details wrong.</div><div><br></div><div>Looking at the Eagle schematic, I see the crystal specified as 20 MHz. In HS mode, that would make the main oscillator run at FOSC = 20 MHz. But if you're using the HSPLL, you could be running at the maximum FOSC = 40 MHz. The latter option would obviously cut the period in half. A quick check of the firmware source shows #pragma config OSC = HS, so you might consider doubling this using HSPLL and the remaining appropriate config changes.</div><div><br></div><div>Anyway, starting with 20 MHz, FOSC/4 = 5 MHz, which is probably where that 5 MHz comment comes from below.</div><div>The 1:8 prescaler takes that down to 625 kHz</div><div>TMR1H:TMR1L of 0x0000 is effectively 0x10000, or 65,536, bringing the frequency down to 9.5367431640625 Hz.</div><div><br></div><div>The reciprocal is exactly 104.8576 ms.</div><div><br></div><div>If you double the PIC speed to its rated maximum using the High Speed Phase Locked Loop (and use a multiplier of 2, not the example of 4 in the data sheet which would bring a 10 MHz crystal up to the 40 MHz maximum), then the period would be 52.4288 ms, but I think you could use the exact same technique that Tom mentioned to adjust for seconds without too much error. You'd just need to alter the values by a factor of two.</div><div><br></div><div>Brian Willoughby</div><div>Sound Consulting</div><div><br></div><br><div><div>On Oct 22, 2014, at 8:30 PM, Mark Webb-Johnson <<a href="mailto:mark@webb-johnson.net">mark@webb-johnson.net</a>> wrote:</div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><blockquote type="cite">Looks good.<div><br></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">(45681/4790)*104.8576 = 1000.0000053411</blockquote></div><div><br></div><div>I've committed that, and will carry on testing tonight.</div><div><br></div><div>Now, of course this depends on the calculation of 104.8576ms per timer1 interrupt. I have no idea where that figure originally came from, or if it is correct. It does looks like the LED count counts 10 of these to get 1 flash a second, so it seems correct. The initialisation for timer1 is:</div><div><br></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>  // Timer 1 enabled, Fosc/4, 16 bit mode, prescaler 1:8</div><div>  T1CON = 0b10110101; // @ 5Mhz => 51.2uS / 256</div><div>  IPR1bits.TMR1IP = 0; // Low priority interrupt</div><div>  PIE1bits.TMR1IE = 1; // Enable interrupt</div><div>  TMR1L = 0;</div><div>  TMR1H = 0;</div></blockquote></div><div><br></div><div>but the @5Mhz comment is incorrect because that is not what our oscillator runs at.</div><div><br></div><div>Regards, Mark.</div></blockquote><div><br></div></div></div></div>_______________________________________________<br>OvmsDev mailing list<br><a href="mailto:OvmsDev@lists.teslaclub.hk">OvmsDev@lists.teslaclub.hk</a><br>http://lists.teslaclub.hk/mailman/listinfo/ovmsdev<br></blockquote></div><br></div></body></html>