Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Codewarrior Embedded > Global Variable...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 350 of 416
Post > Topic >>

Global Variable Lost During Interrupt Routine - HC08 Microcontroller

by "Aria" <akashefi@[EMAIL PROTECTED] > Aug 22, 2005 at 07:02 PM

HI All,

weirdest problem. I have a global variable named maxADR which supposed
to hold the value of the last A to D conversion that was greater than
zero, problem is it gets erased after each interrupt routine! Here's
how I'm doing it:

#include <stdio.h>
....

unsigned char maxADR;

....

void main(void){
....
asm CLR;
for (;;){
 //do nothing
}

interrupt 16 void ADC_ISR(void){
  if (maxADR > 1) doLights();

  ...
  if (ADR > 15) maxADR = ADR/15;
  adrval = ADR;
}

funny thing is as soon as the ADR goes to zero, it seems like maxADR
falls below 1 too ! WHY? anyone know why it's losing its value?

Thanks,
Aria
 




 2 Posts in Topic:
Global Variable Lost During Interrupt Routine - HC08 Microcontro
"Aria" <akas  2005-08-22 19:02:09 
Re: Global Variable Lost During Interrupt Routine - HC08 Microco
"Petr Cach" <  2005-08-22 23:33:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 19:46:40 CDT 2008.