PCOC4 isr_1_ClearPending() doesn't seem to compile.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

I have been converting some PSOC1 to PSOC4 and have come across a problem in compilation.  Perhaps someone can explain it.

   

The chip is CY8C4245AXI-483

   

I have created a very simple schematic with an input pin connected to an ISR component

   

When I use isr1_ClearPending inside the generated ISR, the listing file shows no code.

   

When I comment that line out, the listing file shows what I would expect.

   

Thanks

   

Ian

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Ian, can you please post your complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

Will be much easier that way to check  your generated code.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Bob,

   

Pretty simple.  It started with a UART, then got down to one pin and one interrupt.

   

If you go to the CY_ISR(isr_1_Interrupt) section in isr_1.C and remove the comments on isr_1_ClearPending(); and compile, you will see what I mean.

   

I have included a listing file with some explanation.

   

It is certainly strange.

   

Thanks

   

Ian

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Excerpt from main.lst

   

  40                  .LVL0:
  23:.\main.c      ****         isr_1_ClearPending();
  41                      .loc 1 23 0 discriminator 1
  42 0008 FFF7FEFF         bl    isr_1_ClearPending
  43                  .LVL1:
  24:.\main.c      ****         /* Place your application code here. */

   


and from isr_1.lst

   

 381 0006 1A70             strb    r2, [r3]
 169:.\Generated_Source\PSoC4/isr_1.c ****     
 382                      .loc 1 169 0
 383 0008 FFF7FEFF         bl    isr_1_ClearPending
 384                  .LVL20:
 172:.\Generated_Source\PSoC4/isr_1.c ****

   


so, both ClearPending() did generate code.

   

 

   

BTW: You do not need to code a Clearpending in main() and putting the isr_1_Start into the main loop is an error.

   

A .h file is not meant to keep definitions of variables, only declarations.

   

Additionally .h files need a means to allow them to be included in several files without producing errors due to doubly defined symbols. So in your case:

   

#ifndef Test_h
#define Test_h

   

extern uint8 TestVariable;

   

#endif

   

include that file in both main.c and isr_1_int.c

   

in main.c

   

volatile uint8 TestVariable = 1;   // Global vars changed in a handler must always be "volatile"

   

 

   

I would suggest you to use isr_1_StartEx() which allows you to keep the handler in one of your own files. Changes in the generated files might get overwritten by accident.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thanks Bob, 

   

Perhaps I am missing something or we are misunderstanding each other...

   

I agree with your comments and I would normally use a file 'initialise.c' and a proper header file to call all the start routines and setup. This was just a simplification to try and find what appeared to be the compilation error,

   

I agree  isr_1_ClearPending does generate code but 

   

CY_ISR(isr_1_Interrupt) does not generate code when used in the generated routine.  TestVariable is never set.

   

 159:.\Generated_Source\PSoC4/isr_1.c **** CY_ISR(isr_1_Interrupt)
 160:. {
 161:.     #ifdef isr_1_INTERRUPT_INTERRUPT_CALLBACK
 162:.         isr_1_Interrupt_InterruptCallback();
 163:.    #endif /* isr_1_INTERRUPT_INTERRUPT_CALLBACK */ 
 164:.
 165:.     /*  Place your Interrupt code here. */
 166:.  /* `#START isr_1_Interrupt` */
 167:.     
 168:     TestVariable = 1;               <--------- This line does not get compiled until
 169:.     isr_1_ClearPending();      <--------- this line is removed
 170:.    
 171:.     /* `#END` */
 172:.\Generated_Source\PSoC4/isr_1.c **** }

   

 

   

 

   

 165:.\Generated_Source\PSoC4/isr_1.c ****     /*  Place your Interrupt code here. */
 166:.     /* `#START isr_1_Interrupt` */
 167:     
 168:.     TestVariable = 1;           <---- here we have a compilation
  28                      .loc 1 168 0
  29 0000 0122             mov    r2, #1
  30 0002 014B             ldr    r3, .L2
  31 0004 1A70             strb    r2, [r3]
 169:.     // isr_1_ClearPending();          <----- This has been commented out
 170:.     
 171:.     /* `#END` */
 172:.\Generated_Source\PSoC4/isr_1.c **** }

   

Regards

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Again isr_1.lst:

   

 168:.\Generated_Source\PSoC4/isr_1.c ****     isr_1_ClearPending();
 378                      .loc 1 168 0
 379 0002 0122             mov    r2, #1
 380 0004 024B             ldr    r3, .L36
 381 0006 1A70             strb    r2, [r3] <-- Store TestVariable
 169:.\Generated_Source\PSoC4/isr_1.c ****     
 382                      .loc 1 169 0
 383 0008 FFF7FEFF         bl    isr_1_ClearPending <-- ClearPending
 384                  .LVL20:

   

 

   

Do you really question that the Gnu C Compiler is errornous in such a simple program? When the line for setting the variable is never executed there will be another reason.

   

Edit: Project attached

   

Bob

0 Likes