PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Böse Interrupts



Florianinside
17.04.2006, 12:25
Hallo Forum,
zwischen Eiersuchen und Osterwünsche verteilen lese ich mich das erste mal in die Interrupt meines AVR 169 ein.

Ich habe einen IS471 an meinen Butterfly angeschlossen und möchte bei entsprechendem Signal eine Meldung über das LCD laufen lassen.

Das Problem, dass ich gerade habe ist, dass das Interrupt nicht ausgelöst wird und der entsprechende Programmtext nicht ausgeführt wird.

Ich denke, dass die Fehler in den EIFR (oder wie auch immer die sich schimpfen)-Registern zu finden sind und ich diese falsch anspreche.

Der Quelltext ist nicht groß, das ansprechen des LCD´s klappt prima.


// Auslesen eines IS471-Sensors

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/sleep.h>
#include <inttypes.h>
#include <avr/signal.h>
#include <inttypes.h>
#include "main.h"
#include "lcd_functions.h"
#include "lcd_driver.h"
#include <avr/delay.h>

#define pLCDREG_test (*(char *)(0xEC))

// extern unsigned int LCD_character_table[] PROGMEM;

volatile PGM_P statetext;

void PinChangeInterrupt(void)
{
cli(); // disable interrrupts

statetext = PSTR("wand");
LCD_puts_f(statetext, 1);
LCD_Colon(0);
_delay_loop_2(300000000); // Ja, Pausen in Interrupts sind böse

// Ist diese Zeile hier sinnvoll?
EIFR = (1<<PCIF1) | (1<<PCIF0); // Delete pin change interrupt flags

sei();
}

SIGNAL(SIG_PIN_CHANGE0)
{
PinChangeInterrupt();
}

SIGNAL(SIG_PIN_CHANGE1)
{
PinChangeInterrupt();
}

/************************************************** ***************************
*
* Function name : main
*
* Returns : None
*
* Parameters : None
*
* Purpose : Contains the main loop of the program
*
************************************************** ***************************/
int main(void)
{

DDRB = 0x00; // set Port B for input
//PORTB = 0xFF;
// Enable pin change interrupt on PORTB
PCMSK0 = (1<<PINB1)|(1<<PINB2)|(1<<PINB3)|(1<<PINB4);
PCMSK1 = (1<<PINB1)|(1<<PINB2)|(1<<PINB3)|(1<<PINB4);
EIFR = (1<<1)|(1<<2)|(1<<3)|(1<<4);
EIMSK = (1<<1)|(1<<2)|(1<<3)|(1<<4);

statetext = PSTR("1");

// Program initalization
Initialization();
sei(); // mt __enable_interrupt();

while (1) // Main loop
{

statetext = PSTR("1");
LCD_puts_f(statetext, 1);
LCD_Colon(0);

} //End Main loop

return 0;
}

/************************************************** **************************
*
* Function name : Initialization
*
* Returns : None
*
* Parameters : None
*
* Purpose : Initializate the different modules
*
************************************************** ***************************/
void Initialization(void)
{
/*
CLKPR = (1<<CLKPCE); // set Clock Prescaler Change Enable

// set prescaler = 8, Inter RC 8Mhz / 8 = 1Mhz
CLKPR = (1<<CLKPS1) | (1<<CLKPS0);

// Disable Analog Comparator (power save)
ACSR = (1<<ACD);

// Disable Digital input on PF0-2 (power save)
DIDR1 = (7<<ADC0D);

// mt PORTB = (15<<PORTB0); // Enable pullup on
PORTB = (15<<PB0); // Enable pullup on
// mt PORTE = (15<<PORTE4);
PORTE = (15<<PE4);

sbi(DDRB, 5); // set OC1A as output
sbi(PORTB, 5); // set OC1A high
*/

LCD_Init(); // initialize the LCD
}