EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

interrupts with FX2

Started by jan0385 October 12, 2010
Hello,

do you know where I can find information about setting up an interrupt with
the FX2?

To my knowledge an ISR looks like:

static void MyIsr(void) __interrupt 0
{
   // Clear global USB IRQ
   EXIF &= ~0x10;
..
}

But how do I tell the FX2 to run the ISR when the IRQ0 (INT0 pin) occurs?

Best regards
Jan	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
On 12/10/2010 07:33, jan0385 wrote:
> Hello, > > do you know where I can find information about setting up an interrupt with > the FX2? > > To my knowledge an ISR looks like: > > static void MyIsr(void) __interrupt 0 > { > // Clear global USB IRQ > EXIF&= ~0x10; > .. > } > > But how do I tell the FX2 to run the ISR when the IRQ0 (INT0 pin) occurs? > > Best regards > Jan > > --------------------------------------- > Posted through http://www.EmbeddedRelated.com
Have you tried Google?
>On 12/10/2010 07:33, jan0385 wrote: >> Hello, >> >> do you know where I can find information about setting up an interrupt
with
>> the FX2? >> >> To my knowledge an ISR looks like: >> >> static void MyIsr(void) __interrupt 0 >> { >> // Clear global USB IRQ >> EXIF&= ~0x10; >> .. >> } >> >> But how do I tell the FX2 to run the ISR when the IRQ0 (INT0 pin)
occurs?
>> >> Best regards >> Jan >> >> --------------------------------------- >> Posted through http://www.EmbeddedRelated.com > >Have you tried Google? >
Yes Ok, 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 http://www.EmbeddedRelated.com
On 12/10/2010 13:07, jan0385 wrote:
>> On 12/10/2010 07:33, jan0385 wrote: >>> Hello, >>> >>> do you know where I can find information about setting up an interrupt > with >>> the FX2? >>> >>> To my knowledge an ISR looks like: >>> >>> static void MyIsr(void) __interrupt 0 >>> { >>> // Clear global USB IRQ >>> EXIF&= ~0x10; >>> .. >>> } >>> >>> But how do I tell the FX2 to run the ISR when the IRQ0 (INT0 pin) > occurs? >>> >>> Best regards >>> Jan >>> >>> --------------------------------------- >>> Posted through http://www.EmbeddedRelated.com >> >> Have you tried Google? >> > > Yes Ok, > > 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 http://www.EmbeddedRelated.com
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. Does it compile?
On Tue, 12 Oct 2010 07:07:21 -0500, "jan0385"
<Jan-Erik.Lange@n_o_s_p_a_m.haw-hamburg.de> wrote:


>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?
There isn't a universal convention for tagging interrupts. You'll need to refer to the documentation for the particular assembler you're using. -- Rich Webb Norfolk, VA
There occur no errors during compilation.
The syntax for defining an ISR using the sdcc compiler is (I looked in the
manual of sdcc):
void timer_isr (void) __interrupt (1) __using (1)

the keyword using is optional. For the number after __interrupt I take 0
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, the
firmware is not running. It seems the error is depending of the ISR
definition...

	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
On 12/10/2010 14:32, jan0385 wrote:
> There occur no errors during compilation. > The syntax for defining an ISR using the sdcc compiler is (I looked in the > manual of sdcc): > void timer_isr (void) __interrupt (1) __using (1) > > the keyword using is optional. For the number after __interrupt I take 0 > 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, the > firmware is not running. It seems the error is depending of the ISR > definition... >
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!
> > --------------------------------------- > Posted through http://www.EmbeddedRelated.com
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 http://www.EmbeddedRelated.com
On 12/10/2010 15:03, jan0385 wrote:
> 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 http://www.EmbeddedRelated.com
In order to make the conversation easier to follow, please quote the last message as I am doing. So I am assuming therefore that the USB part is in some code elsewhere? Are you clearing the interrupt flag? If you don't the interrupt will keep firing and the rest of the program will never be able to run.
>On 12/10/2010 15:03, jan0385 wrote: >> 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 http://www.EmbeddedRelated.com > >In order to make the conversation easier to follow, please quote the >last message as I am doing. > >So I am assuming therefore that the USB part is in some code elsewhere?
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 http://www.triplespark.net/elec/periph/USB-FX2/software/local_examples.html#hello_world_usb void main(void) { Initialize(); for(;;) { // Wait for the EP6 buffer to become non-full. if(!(EP6CS & (1<<3))) { SetUpBufToTransfer(); } } } In the SetUpBufToTransfer(); function, data is put in the EP buffer and made ready for transmission.
> >Are you clearing the interrupt flag? If you don't the interrupt will >keep firing and the rest of the program will never be able to run. >
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 http://www.EmbeddedRelated.com

The 2024 Embedded Online Conference