blinking LED's

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

cross mob
Anonymous
Not applicable
0 Likes
7 Replies
Anonymous
Not applicable
        Hi The program controls two LEDs (they are only blinking), one diode (LCD_RED) in the timer interrupt and second (LCD_SWITCH) in the main loop of the program. When I'm enabling global interrupt (M8C_EnableCInt) only LED_RED in the interrupt blinking, but second LCD_SWITCH didn't and I don't know why. When I'm disabling global interrupt (by coment M8C_EnableCInt), only LCD_SWITCH in the main loop blinking. Why only one LED changed state in the interrupt works but in the main loop doesn't ? //---------------------------------------------------------------------------- // C main line //---------------------------------------------------------------------------- #include        // part specific constants and macros #include "PSoCAPI.h" // PSoC API definitions for all User Modules #pragma interrupt_handler timer_isr int counter; void timer_isr(void) { //Place interrupt service code here if (counter==1000) { LED_RED_Invert(); counter = 0; } counter++; return; } void main(void) { // M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts // Insert your main routine code here. LED_RED_Start(); LED_SWITCH_Start(); Timer8_WritePeriod(0x63); Timer8_WriteCompareValue(0x00); //M8C_EnableGInt; Timer8_EnableInt(); Timer8_Start(); while (1) { for (i=0;i<100;i++) LCD_Delay50uTimes(200); LED_SWITCH_Invert(); } }   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome to the forum, Maniek!

   

I assume your red led handled in the interrupt does not blink with the calculated value of the timer?

   

When you provide us with the complete project archive we can exactly see where your issue is to be found. To do so, use

   

Designer-> File -> Archive Project

   

and attach the resulting file to your next post.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable
        Hi Bob thank you for your answer, Red led blink good, but problem is with led 'LED_SWITCH'. When interrupt is on the led 'LED_SWITCH' not blinking at all.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Looks not too bad, so far. You should give your variable "counter" an initial value.

   

Can't see any bug in code.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi Bob,

   

I also do not see the error. Global variables are initialized to zero, unless it is otherwise in PsoC Designer.
The problem is that when interrupt are OFF diode LED LED_SWITCH1 works (blinking), but when interrupt are ON it seems to me that program don't return form interrupt routine and did not perform program in the main loop (where I am changing the status led diode LED_SWITCH1).
I was also changing interrupt type to capture and blinking led diode LED_SWITCH1 works.

0 Likes
Anonymous
Not applicable
        I created a a new project and the same thing was happening. I uninstalled and installed PSoC Designer 5.4 again and it's working like I want. Then you for your time Bob 😉   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Weird!!!

   

I would suggest you to switch to PSoC4. More modern CPU, compiler and Creator software, debug capabilities without an ICE.

   

 

   

Bob

0 Likes