With "information snippets" I found with google (yes I tried google) I wrote the folowing code:
.... // PORTACFG: FLAGD SLCS(*) 0 0 0 0 INT1 INT0 // INT0 on PortA PORTACFG = 0x01; IP = 0x01; // INT0 to high priority IE = 0x81; // global interupt enable an enable interupts from INT0
..
static void MyIsr(void) __interrupt 0 { // My Interrupt handler for INT0 }
....
Does the 0 after the __interrupt stand for the first row in the interupt vector table or?
--------------------------------------- Posted through
The exact syntax for the interrupt handler will depend on the compiler. Check the data sheet/user manual for your part and this will give you information on the interrupt vector table and whether you need to use 0 or some other, although your code comments suggest that 0 is the correct one.
There occur no errors during compilation. The syntax for defining an ISR using the sdcc compiler is (I looked in th manual of sdcc): void timer_isr (void) __interrupt (1) __using (1)
the keyword using is optional. For the number after __interrupt I take for INT0
When I uncomment my ISR, the firmware is running without errors.
And the 0 for INT0 should be right too.
Even if I disable all interrupts and I have my ISR uncommented, th firmware is not running. It seems the error is depending of the IS definition...
--------------------------------------- Posted through
How do you know it's not running? How will you know when it is running correctly? Also you appear to be contradicting yourself, above you say the firmware *is* running without errors!
When I don't define this ISR, the firmware is running because..
With my Computer I send bulk requests to the FX2. Ok, and when I define the ISR the the FX2 don't respond to this requests. When I don't define this ISR, the FX2 sends an USB message after receiving the bulk request.
--------------------------------------- Posted through
The FX2 is configured, that he should answer to a bulk request by send an usb message to the bus.
The source I got from
formatting link
void main(void) { Initialize(); for(;;) { // Wait for the EP6 buffer to become non-full. if(!(EP6CS & (1Are you clearing the interrupt flag? If you don't the interrupt will
No the flag should be cleared automaticaly(register TCON). Or is this not
8051 like? This is my interrupt initialization:
// PORTACFG: FLAGD SLCS(*) 0 0 0 0 INT1 INT0 // INT0 am PortA PORTACFG = 0x01; SYNCDELAY; // (delay maybe not needed) IP = 0x01; SYNCDELAY; //xxxxxxx1 // | // INT0 auf high priority IE = 0x81; SYNCDELAY; //1xxxxxx1 //| | //| Enable interrupts for INT0 //Global interrupt enable TCON |= 0x01; //xxxxxxx1 // || // |1=edge sensitive // Is set when a negaitve cklock edge is detected on the //INT0 pin and is automaticaly cleared when the FX2 //vectors to the corresponding ISR. (TRM of FX2)
--------------------------------------- Posted through
Ok, I overlooked the fact, that using ISRs with the FX2 you have to add the line to the main()-file:
#pragma NOIV
This setting is required to set up EZUSB-specific interrupt vector table.
Then you have to put the ISR in another file than the file, where this statement is.
The USB tranfer is not disturbed now. Thats an improvement for the problem. But there's a further problem.
In the ISR I increment a variable. This variable I send over USB to my PC to see if the ISR ran. But it is not incremented. Incrementing it in a "normal" function is going well.
I declared the variable in an extra header file. The two files (file with main() and the file with the ISR) now can see the varibale.
static volatile char value=0;
By the way, there is no compilation error. Can you see a failure defining the variable or another faliure?
--------------------------------------- Posted through
The variable should be declared in one of your c files and then extern'd in the header file. It sounds like the way you have done it will create two separate variables with the same name.
Even better is to only declare the variable in one of the c files and then create a function to access it from another c file. That way you can protect the variable from erroneous writes, or make it so that it is only readable for example.
It's not good practice but it is permitted and might be useful in special circumstances. This is a "should not" rather than a "can not."
The storage class specifier "static" declares that the functions have internal linkage. This can't be paired with the specifier "extern." From
6.9.1 Function Definitions "The storage-class specifier, if any, in the declaration specifiers shall be either extern or static."
It is permitted (and common practice) to have the functions declared in the header files as extern and then in exactly one .c file (which includes the header) to write the function definitions.
Also: the function prototypes above really ought to have parameter lists.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.