cancel
Showing results for 
Search instead for 
Did you mean: 

USB Low-Full-High Speed Peripherals

JeBo_4132831
New Contributor II

Hi,

I would like to use TIMER0 of the FX2LP18.

I follow the code available in  https://www.cypress.com/file/134421/download 

I've adapted it cause i'm using an Eclipse Project and SDCC.

As soon as i add the TIMER0 ISR in my project, no more enumeration 😞

All works fine if i remove it.

Is there any project example using SDCC/Eclipse ?

Or Anyone could check my project ?

Regards

0 Likes
1 Solution
PranavaYN
Moderator
Moderator

Hi,

Here is a thread which discusses your query in detail - https://sourceforge.net/p/sdcc/discussion/1865/thread/6010fcd1/

Please go through the following lines in KBA - https://community.cypress.com/t5/Knowledge-Base-Articles/FX2LP-I2C-Based-Debug-with-SDCC-on-Eclipse-...

"For enabling the general I2C operations, the USBJmpTb.asm file needs to be modified. This is done to hard code the address of I2C ISR since SDCC compiler, by default places the address in an arbitrary location, which will cause issues in the ISR call and the USB enumeration. " 

You can also use http://sdcc.sourceforge.net/doc/sdccman.pdf SDCC User guide for your reference as well.

Best regards,
Pranava

View solution in original post

3 Replies
PranavaYN
Moderator
Moderator

Hi,

Please refer to the following KBA which explains why an ISR might not be executed when using SDCC compiler. https://community.cypress.com/t5/Knowledge-Base-Articles/FX2-FX2LP-SDCC-Eclipse-Project-Interrupt-no...

Please follow the changes specified in the KBA and check if that solves your issue with timer.

If not please share your project so that we can check at our end.

Best regards,
Pranava
0 Likes
JeBo_4132831
New Contributor II

Hi, Thanks for your answer and sorry for my late answer. But really a lot of works ..

TO sump up : I'm now able to generate timer interrupt and generate a good firmware but is is NOT CRYSTAL Clear of the SDCC compiler/linker behavior.Sometimes, depending on the way the interrup are managed, some vectors disappered in the final .HEx file (driving obviously to a non working firmware).

 

I do not undertand clearly what happens.

Another question : Why for I2C Interrupts there is something the the USB JMP table

.org 0x004B ljmp __i2c_isr

while it is not needed for timer0 for instance  Really it is not clear ..... if yu can explain me, pehaps something is wrong in my eclipse SDCC project ....

By using the code below it works. I've add one file isr.c/isr.h in my project.

 

Code @ the end.

 

#include "isr.h"

 

extern BOOL Timer0_Elapsed;

 

void InitTIMER0(void)

{

 

      EA = 0; // disables all interrupts

      TR0 = 0; // stops Timer 0

      CKCON = 0x03; // Timer 0 using CLKOUT/12

      TMOD &= ~0x0F; // clear Timer 0 mode bits

      TMOD |= 0x01; // setup Timer 0 as a 16-bit timer

      TL0 = (0x63C0 & 0x00FF); // loads the timer counts

      TH0 = (0x63C0 >> 8);

      PT0 = 0; // sets the Timer 0 interrupt to low priority

      ET0 = 1; // enables Timer 0 interrupt

      TR0 = 1; // starts Timer 0

      EA = 1; // enables all interrupts

 

}

 

void external_int_0 (void) __interrupt INT0_VECT

{

      // Nothing to DO

}

 

void timer0_int (void) __interrupt TMR0_VECT

{

      Timer0_Elapsed = TRUE;

}

 

void external_int_1 (void) __interrupt INT1_VECT

{

      // Nothing to DO

}

 

void timer1_int (void) __interrupt TMR1_VECT

{

      // Nothing to DO

}

/*

void com0_int (void) __interrupt COM0_VECT

{

      // Nothing to DO

}

 

void timer2_int (void) __interrupt TMR2_VECT   // interrupt vector 0x0013

{

      // Nothing to DO

}

 

void com1_int (void) __interrupt COM1_VECT   // interrupt vector 0x0013

{

      // Nothing to DO

}

 

void external_int_4 (void) __interrupt INT4_VECT   // interrupt vector 0x0013

{

      // Nothing to DO

}

 

void external_int_5 (void) __interrupt INT5_VECT   // interrupt vector 0x0013

{

      // Nothing to DO

}

 

void external_int_6 (void) __interrupt INT6_VECT   // interrupt vector 0x0013

{

      // Nothing to DO

}

*/

// DOES NOT WORK IF PUT HERE !!! MANDATORY TO ADD IT INTO USBJmpTb.asm ... WHY ???

 

//void i2c_int (void) __interrupt I2C_VECT   // interrupt vector 0x0013

//{

      //TCON &= 0xF7;

//    toggle();

//}

0 Likes
PranavaYN
Moderator
Moderator

Hi,

Here is a thread which discusses your query in detail - https://sourceforge.net/p/sdcc/discussion/1865/thread/6010fcd1/

Please go through the following lines in KBA - https://community.cypress.com/t5/Knowledge-Base-Articles/FX2LP-I2C-Based-Debug-with-SDCC-on-Eclipse-...

"For enabling the general I2C operations, the USBJmpTb.asm file needs to be modified. This is done to hard code the address of I2C ISR since SDCC compiler, by default places the address in an arbitrary location, which will cause issues in the ISR call and the USB enumeration. " 

You can also use http://sdcc.sourceforge.net/doc/sdccman.pdf SDCC User guide for your reference as well.

Best regards,
Pranava

View solution in original post