Adviice  on how to make  variable in SysTick_interrupt_timer visible globally & advise on future WDT

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

cross mob
Anonymous
Not applicable

I am starting to add several internal software timers to a psoc4 design starting on the  cykit-049  (most will probably be 1 sec decrement values but some could be minutes) .  Can someone give me some advise on best path.  I have declared a static volatile uint8 in main as global and also inside of the SysTick_interrupt_timer with a clean compile.  However when I decrement the var in  the systick it obviously doesn't decrement in main.  Should I be using extern since SysTick is a separate file? 

   

At some point I will be adding a WDT so maybe I need advice to move away from SysTick and into a WDT type interrupt but I still am confused on how to make a global in main visitable and modifiable in an interrupt routine such as SysTick.  Is there an example that would help me understand this shared variable concept ?

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

A global variable declared in main.c is global and can be accessed from other modules when declared as extern. When you declare it again in a different file it will be a second variable that just happens to have the same name as that in main.c.

   

 

   

Bob

View solution in original post

0 Likes
2 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Please post your current code by clicking on file in Psoc Creator then click on create workspace bundle so we can check your code.

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

A global variable declared in main.c is global and can be accessed from other modules when declared as extern. When you declare it again in a different file it will be a second variable that just happens to have the same name as that in main.c.

   

 

   

Bob

0 Likes