Thanks again, picandmix, you are a nice guy to help so much.
I realized that I was creating my own troubles by making my test program overly complicated, so I thought more carefully and tried to write some code that was short and to the point.
The result is:
1) The chip now blinks the LEDS and has proved it can work correctly with in Priority Interrupt Mode and Hi-Tech 9.80 works.
This is the short test and uses minimal code to do the job
2) I tested the program also by editing in the short version I just created into a monster c-source file that I does math and has so much nonsense code that it uses 98.6% of available code space. Compiles and works perfect as well.
//=============================== This One Works! ========================================
/* Test for PIC18F25K22 that works
My Second PIC18F25K22 Program:
Program only slowly blinks LEDs and shows operation of priority mode interrupts
*/
#include <htc.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <P18f25k22.h>
/*
#pragma config FOSC=0x8; //By itself also sets PRICLKEN=1 bit5 of CONFIG1H
#pragma config PRICLKEN=1; //Primary Clock is always enabled
#pragma config FOSC=0x5; //Coofig1H Default 0x2500 0001=0x25
#pragma config BORV=0; //Config2L Vdd level for BOREN to reset at
#pragma config BOREN=0; //BOREN Disabled
#pragma config PWRTEN=1; // 0002=0x1F
#pragma config WDTPS=0; //Ratio of Number of Clocks/WDTimerTic
#pragma config WDTEN=0; //WatchDog Enable Disabled 0003=0x3F ater erase
#pragma config MCLRE=1; //Pin 1 is *MCLR reset, not I/O pin
#pragma config PBADEN=0; //PORTB<0:5>are I/O pins not A2d inputs after reset
#pragma config T3CMX=1; //HFINTOSC is not delayed at startup
#pragma config CCP2MX=1; //CCP2 in/out is Mtplxd with RC2
#pragma config DEBUG=1; //Background Debugger is disabled
#pragma config XINST=0; //Extended instruction set DISABLED
#pragma config LVP=0; //LV programming disabled
#pragma config STVREN=1; //Reset on Stack Overflow or Underflow Enabled
*/ //Allow internal/external clock swithover in OSCCON
#pragma config IESO=1; //Needs to be=1 for SCS to work to set clk source
#pragma config PBADEN=0;
#pragma config WDTEN=0; //WatchDog Enable Disabled 0003=0x3F ater erase
//Bit 7 6 5 4 3210
// IESO FCMEM PRICLKEN PLLCFG OSC SELECT
// Int-Ext FailSafe no effect 0010 Xtal
// ClkSwEn Clock Mon HFINTOSC 1000 INTHFOSC
// 1=En 0=off 1=En x 1000
//OSCCON SCS=0 to select above or else no 64MHz operation
__PROG_CONFIG(1,0x8800); //Internal Osc Block at 16MHz x 4 with PLL
__PROG_CONFIG(2,0x0); //BOREN and WDTEN both disabled
__PROG_CONFIG(3,0xBD00); //PBADEN disabled PORTB<5:0>are I/O not A2d at reset
__PROG_CONFIG(4,0x85);
__PROG_CONFIG(5,0xC00F); //CONFIG4 to CONFIG7 set Read and Write protects
__PROG_CONFIG(6,0xE00F);
__PROG_CONFIG(7,0x400F);
#define Off 0
#define OFF 0
#define off 0
#define On 1
#define ON 1
#define on 1
#define None 0
//Break the ports down to their bits
#define PB(port,bit) ((unsigned) & (port)*8 + (bit))
static bit abit0 @ PB(PORTA,0);
static bit abit1 @ PB(PORTA,1);
static bit abit2 @ PB(PORTA,2);
static bit abit3 @ PB(PORTA,3);
static bit abit4 @ PB(PORTA,4);
static bit abit5 @ PB(PORTA,5);
static bit abit6 @ PB(PORTA,6);
static bit abit7 @ PB(PORTA,7);
static bit bbit0 @ PB(PORTB,0);
static bit bbit1 @ PB(PORTB,1);
static bit bbit2 @ PB(PORTB,2);
static bit bbit3 @ PB(PORTB,3);
static bit bbit4 @ PB(PORTB,4);
static bit bbit5 @ PB(PORTB,5);
static bit bbit6 @ PB(PORTB,6);
static bit bbit7 @ PB(PORTB,7);
static bit cbit0 @ PB(PORTC,0);
static bit cbit1 @ PB(PORTC,1);
static bit cbit2 @ PB(PORTC,2);
static bit cbit3 @ PB(PORTC,3);
static bit cbit4 @ PB(PORTC,4);
static bit cbit5 @ PB(PORTC,5);
static bit cbit6 @ PB(PORTC,6);
static bit cbit7 @ PB(PORTC,7);
static double ttemp=0;
void interrupt high_priority(void)
{
if (INT0IF) //When INT0IE is enabled, bbit1 lights and stays on when INTI0 is triggered falling edge
{ INT0IF = 0;
bbit1=1;
}
if (TMR1IF)
{ TMR1IF=0; //During the time INTI0 is enabled TMR1IF is manually set and bbit3 toggles with Sw press
if(bbit3==0) //In this case, if TMR1IP=1, it is hi-priority, INT0 is always hi-priority
{ bbit3=1;
}
else bbit3=0;
}
}//end of high-priority interrupt
void interrupt low_priority lp(void)
{
if(INT0IF) //During the time INT0IE=0 and TMR1IP = 0, lo-priority, INTIOF will be set in any case
{ INT0IF=0; //by a swith press
bbit1=0; //I can tell I am in this mode also because bbit1 LED is not lit
}
if (TMR1IF) //If TMR1IF is triggered by a Sw. press, bbit4 will toggle
{ TMR1IF=0;
if(bbit4==0)
{ bbit4=1;
}
else bbit4=0;
}
}// end of low priority interrupt
//____________________________ MAIN ___________________________________
void main(void)
{
Reset:
OSCCON=0x70; //Selects Int Osc Block Clk as internal clock source
OSCTUNE=0x5F; //Highest Internal OSC Freq OSCTUNE<0:5> set freq. PLLEN=bit6
//OSCTUNE<6:0>set freq 011111 =16MHz
PLLEN=1; //Enables PLL Fosc=Fosc*4 = 64MHz with Internal 16MHz osc.
//PLLRDY //Status Bit 1=PLL ON
INTEDG0=0; //interrupt on falling edge
PORTB=1;
TRISB = 0x1; //INTO pin set for digital input
INT0IE = 1; //Enable INT0 interrupt
INT0IF = 0; //needs to be reset in either ISR
TMR1IE=1; //TMR1IF is manually set along with INT0IF in this test program
IPEN=1; //Interrupt Priority Mode enabled
/* NOT NEEDED
PEIE=1;
PIE1=1;
PIE2=1;
*/
GIEL=1; //enables lo-priority IRQs
GIEH=1; //enables Lo and Hi priority IRQs, if off, all IRQ's are disabled
//----------------------------------------------------------------------
Start:
for(ttemp=0;ttemp<120000;ttemp++)//An approx several seconds timed loop at 16MHz x 4
{ bbit7=1;
//There is a a 1K resistor connected to each LED to Vss, bbit7 LED is just a heartbeat
INT0IE=1;
TMR1IP=1; //For this timed interval TMR1 is hi-priority
if(bbit0==0)TMR1IF=1; //Manual sets both IRQ flags with a sw.
//During this interval, only bbit3 should toggle with a debounced sw. press
}
for(ttemp=0;ttemp<120000;ttemp++) //Takes about several seconds at 16MHz x 4
{
bbit7=0; //during this timed interval bbit4 should toggle with each clean sw press
INT0IE=0;
TMR1IP=0; //During the SW timed interval, TMR1IF is low-priority
if(bbit0==0)TMR1IF=1; //This still triggers INT0IF even if it's interrupt is disabled
}
goto Start;
}
//======================== END of MAIN ==================================