aljamieson
Newbie level 1
SETUP
Chip: PIC16F690
IDE: MPLAB (v8.30)
Compiler: HI-TECH C PRO (v9.65 Lite)
Programmer: PICkit2 (SW v2.50, FW v1.51, OS v2.32)
SITUATION
I have been building a project with the above setup, everything was working fine and my project was near completion. However I kept running out of room due to the reduced code compression of the Lite C compiler.
So, instead of spending £100's on a compiler upgrade, I looked at upgrading my setup to a PIC18 series with more memory (for a few £), which involved upgrading my PICkit2 firmware/OS... I'm fairly certain that's when it all went wrong (it was late at night and I was making changes to many aspects of the project!)
My project relies on critical timing for USART and IR communication and what used to be a 10ms interrupt timer is now a 15.92ms timer.
I tried reverting the PICkit2, which didn't work. I have even tried a new PICkit2 which didn't help either. I have checked, double checked and triple checked all IDE, compiler and PICkit2 settings and cannot see what is causing the change.
SANITY CHECK
As a sanity check, to make sure it wasn't a software issue, I started with a clean project and wrote the simple code below to generate what should be a square wave with 10ms mark followed by 10ms space...
Can someone please verify that this should generate the aforementioned square wave, and also offer any ideas as to why I am seeing this sudden but consistent slowdown of the timers
Thanks!
Al
---------- Post added at 21:34 ---------- Previous post was at 21:30 ----------
PS - the device still erases, programs and verifies perfectly. The increased time of 15.92ms was measured using the PICkit2 (I even tried calibrating the VDD to see if that helped)
Chip: PIC16F690
IDE: MPLAB (v8.30)
Compiler: HI-TECH C PRO (v9.65 Lite)
Programmer: PICkit2 (SW v2.50, FW v1.51, OS v2.32)
SITUATION
I have been building a project with the above setup, everything was working fine and my project was near completion. However I kept running out of room due to the reduced code compression of the Lite C compiler.
So, instead of spending £100's on a compiler upgrade, I looked at upgrading my setup to a PIC18 series with more memory (for a few £), which involved upgrading my PICkit2 firmware/OS... I'm fairly certain that's when it all went wrong (it was late at night and I was making changes to many aspects of the project!)
My project relies on critical timing for USART and IR communication and what used to be a 10ms interrupt timer is now a 15.92ms timer.
I tried reverting the PICkit2, which didn't work. I have even tried a new PICkit2 which didn't help either. I have checked, double checked and triple checked all IDE, compiler and PICkit2 settings and cannot see what is causing the change.
SANITY CHECK
As a sanity check, to make sure it wasn't a software issue, I started with a clean project and wrote the simple code below to generate what should be a square wave with 10ms mark followed by 10ms space...
Can someone please verify that this should generate the aforementioned square wave, and also offer any ideas as to why I am seeing this sudden but consistent slowdown of the timers
Thanks!
Al
Code:
#include <htc.h>
void main(void)
{
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT & BOREN & IESODIS & FCMDIS);
OSCCON=0x71; // internal clock, Fosc = 8MHz
OSCTUNE = 0; // set to factory cal, just to be sure
// CONFIGURE TIMER 1 for 10ms interrupts
TMR1IE = 1; // enable timer1 overflow interrupt
TMR1CS = 0; // internal clock (Fosc/4) = 2MHz
T1CKPS1 = 0; // pre-scalar set to 1:1, so T1clock = 2MHz
T1CKPS0 = 0;
TMR1H = 0xB1; // 10ms is 20000 (0x4E20) counts at 2MHz
TMR1L = 0xE0; // so, preload is 0x10000 - 0x4E20 = 0xB1E0
TMR1ON = 1;
PEIE = 1; // enable peripheral interrupts
TRISA0 = 0; // configure toggle bit, for logic tool
GIE = 1; // global interrupt enable
for(;;) { NOP(); }
}
static void interrupt isr(void)
{
static bit toggle = 0;
if(TMR1IF)
{
// preload register for overflow after another 10ms
TMR1ON =0;
TMR1H = 0xB1;
TMR1L = 0xE0;
TMR1ON =1;
// toggle a pin for logic tool
if(toggle == 0) { RA0=1; } else { RA0=0; }
toggle = !toggle;
TMR1IF = 0; // clear interrupt flag
}
}
---------- Post added at 21:34 ---------- Previous post was at 21:30 ----------
PS - the device still erases, programs and verifies perfectly. The increased time of 15.92ms was measured using the PICkit2 (I even tried calibrating the VDD to see if that helped)