Pumpkin, Inc.

Pumpkin User Forums

Timer

For issues specific to Microchip's PICmicro® MCUs, including compilers (e.g. HI-TECH PICC & PICC-18, Microchip MPLAB®-C18) and IDEs (e.g. Microchip MPLAB®).

Timer

Postby Raj » Mon Dec 22, 2003 8:54 am

Hi,

I was using pic 18F452 running on the pic dem 2 plus board at 4Mhz. The TMR0_RELOAD value was 156 which gave me a 100 ticks = 1 second. Can u please tell me how the calculation works as I have now upgraded the hardware to pic 18F8720 running at 20 Mhz and I am not sure to what value I need to change to get a time period of 10 sec to signal a message.

code...

if( iHeartBeatTick >= (unsigned) 1000 )
// 1000 Ticks = 10 Sec
{
iHeartBeatTick = 0;
OSSignalMsgQ(SMSMsgQ_ECBP, (OStypeMsgP) uc_Heartbeat_SMS);
Msg.ValidMsg = (unsigned) 1;
}

Thanks a lot,
Raj

Raj
 
Posts: 7
Joined: Wed Nov 19, 2003 12:00 am
Location: Erie, PA, USA

Re: Timer

Postby aek » Mon Dec 22, 2003 9:46 am

Hi Raj.

Well, 20MHz/4MHz is 5, so your tick rate has got faster by a factor of 5, all other things unchanged.

1000 ticks are now 2 seconds instead of 10, so your code snippet would only change by >= (unsigned) 5000.

If I interpret what you wrote correctly, this is just a PIC issue and has nothing to do with Salvo per se.

In terms of [b]Salvo's[b] timer requirements, all else being equal, you're now calling OSTimer() 5 times faster than before, and so all your task delays have dropped by a factor of 5. To "re-scale" Salvo's delays back to what you had at 4MHz, you'll need to re-configure Timer0 to roll over 5 times more slowly than before -- for that, you'll need to change the prescalar (see salvo ut u1main.h, Init()) and the relaod value TMR0_RELOAD (salvo ut u1isr.h). Or, you can put a software divide-by-5 prescalar in the ISR that calls OSTimer(). Or, with Salvo Pro and a source-code build, you'd set OSTIMER_PRESCALAR to 5 and rebuild.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm


Return to PICmicro MCUs

Who is online

Users browsing this forum: No registered users and 2 guests

cron