We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Morning,
I have some stupid troubles with my SAB80C535 µP. I'm trying to read a acceleration sensor (ADXL202JE) with timer 1 and 2. It works aproximatily fine, excepting the "turbulent" resolution, when the timers work separately. But when i put the two timers together in the main programm then all is messed up. The equation is all disturbed and i get astronomical numbers close to ininit or zero. Can it be posible that the timer 1 and 2 cant work together or are there any priority confuses?? Its driving me crazy !!!!!
Thanks for any answer....
This is the ISR:
void timer1_Int (void) interrupt 2 // Y-Achse T1 { // Diese ISR wird die Impulsbreite T1 (ms) für die Y-Achse aufnehmen // und wird dann mit der Periodendauer T2 (die für X und Y gleich ist) // als Algorithmus die Beschleunigung ausgeben. TR1 = 0; // Timer 1 gestoppt // Timer 1 Register einlesen und g-Wert ausrechnen für Y T1_Y = TH1; T1_Y = T1_Y << 8; T1_Y = T1_Y | TL1; // Timer 1 Register löschen und Interrupt Routine verlassen // TH1 = 0; // Register mit Zählwert // TL1 = 0; // von T1 löschen test_Y = 1; EX1 = 0; IE1 = 0; // Interrupt flag löschen } void timer2_CC0_Int (void) interrupt 10 // X-Achse T1 { // Diese ISR wird die Impulsbreite für die X-Achse einlesen // und zusammmen mit T2 den Beschlwert ausgeben T2CON = 0x40; // Timer 2 stoppen CCEN = 0x00; // Register der CC0 einlesen und g-Wert ausrechnen für X T1_X = CRCH; // Wert aus den Registern der T1_X = T1_X << 8; // Capture-Unit auslesen T1_X = T1_X | CRCL; // Register von Timer 2 löschen TL2 = 0; // Zählregister des TH2 = 0; // Timers und der // Register der CC1 löschen CRCL = 0; // Capture unit CC0 CRCH = 0; // löschen test_X = 1; // ISR Laufvariable setzen IEX3 = 0; } void timer2_CC1_Int (void) interrupt 11 // X & Y-Achse T2 { // Diese ISR wird die Periodendauer für die X und Y-Achse // T2 einlesen und weiterverarbeiten T2CON = 0x40; // Timer 2 stoppen CCEN = 0x00; // Register der CC1 einlesen und Periodendauer T2 speichern T2 = CCH1; T2 = T2 << 8; T2 = T2 | CCL1; // Register von Timer 2 löschen TL2 = 0; TH2 = 0; // Register der CC1 löschen CCL1 = 0; CCH1 = 0; test_T2 = 1; // Laufvariable setzen IEX4 = 0; // Interrupt flag löschen }
The comments are in german so if you have questions dont be afraid to ask. Thanks