Searching \ for '[PIC]: 18F2320 TMR0 Interrupt' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ints.htm?key=interrupt
Search entire site for: '18F2320 TMR0 Interrupt'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 18F2320 TMR0 Interrupt'
2004\02\26@231037 by Nick Veys

flavicon
face
Hi PICList, long time no problem, time to change that! :)  Someone smack
me, I have to be doing something absurd.

I can't get the flippin' TMR0 interrupt to fire on the 18F2320.  I can
get the TMR0IF flag to trigger, I can poll it and see it happen, that
works no problem, so I know the timer is running, and overflowing
correctly.  I just can't get the actual low_priority ISR to be called,
could be a Hi-Tech C problem (my misuse of it most likely) so I'm not
sure.  I've tried simply setting TMR0IF and the interrupt still won't go
off.  I'm just trying to light a damn LED now when either ISR invokes.
Here's my current code, quite simple:

----- SNIP ----- ----- SNIP ----- ----- SNIP ----- ----- SNIP -----

void main() {
  init(); // setup ports, registers, etc...
  initPWM(); // start PWM sequence
  initInterrupts(); // setup interrupt masks, etc

  RB4 = RB5 = 1;

  while(1);
}

void init() {
  IRCF2 = IRCF1 = IRCF0 = 1; // 8MHz
  SCS1 = 1; // Internal oscillator select

  ADCON1 = 0x0C; // Internal ref, 2-0 Analog

  TRISA = 0b00111111; // See pinout
  TRISB = 0b11001111; // See pinout
  TRISC = 0b10000000; // See pinout
}

void initPWM() {
  T0CON = 0b01000110; // internal, 8-bit, 1:128 prescalar
  TMR0H = TMR0L = 0; // clear TMR0
  TMR0ON = 1; // turn on TMR0
}

void initInterrupts() {
  IPEN = 1; // enable interrupt priorities

  TMR0IP = 0; // TMR0 is low priority
  TMR0IE = 1; // enable TRM0 interrupt
  TMR0IF = 0; // clear pending interrupts

  GIEL = 1; // enable low priority interrupts
}

void interrupt ISR() {
  RB4 = 0;
}

void interrupt low_priority ISR_LOW() {
  RB5 = 0;
}

------ SNIP ------ ----- SNIP ----- ----- SNIP ----- ----- SNIP -----

This is my first venture into 18-series and interrupt priorities, so I'm
hoping I'm missing something, but the datasheet simply says to set the
priority, masking and enable low-priority interrupts and it should be
working, which makes sense, yet nothing it happening.

Suggestions are welcome! :)

Thanks in advance,
Nick Veys

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2004\02\27@001945 by piclist

flavicon
face
On Thu, 26 Feb 2004, Nick Veys wrote:

> void initInterrupts() {
>    IPEN = 1; // enable interrupt priorities
>
>    TMR0IP = 0; // TMR0 is low priority
>    TMR0IE = 1; // enable TRM0 interrupt
>    TMR0IF = 0; // clear pending interrupts
>
>    GIEL = 1; // enable low priority interrupts
> }

> This is my first venture into 18-series and interrupt priorities, so I'm
> hoping I'm missing something, but the datasheet simply says to set the
> priority, masking and enable low-priority interrupts and it should be
> working, which makes sense, yet nothing it happening.

You need to set GIEH.  The datasheet is lacking, if not completely
erroneous in this area.  You might want to refer to the 18C family
document for more details.

10.3.1.2 Low Priority Interrupts

[ ... ]

The GIE/GIEH bit's function has not changed in that it still
enables/disables all interrupts, however, it is only cleared by
hardware when servicing a high priority interrupt.

--
John W. Temples, III

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2004\02\27@003725 by Nick Veys

flavicon
face
And viola, it's fixed.  That's an annoying doc oversight, thanks for the
tip!

spam_OUTpiclistTakeThisOuTspamXARGS.COM wrote:

{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

More... (looser matching)
- Last day of these posts
- In 2004 , 2005 only
- Today
- New search...