Jump to content

Interrupt function not triggered

Recommended Posts

MSP430G2 Rev 1.5 with a G2553. Energia 1.8 on Linux debian.

Schematic of test circuit, and full sketch attached.

The device should open (raise) or close (lower) the door for my chickens based on the light level. In the full board I have a H-bridge, 16V Li ion battery and a windscreen wiper motor from a car.
The full board also has HW debouncing - with issues. The door is guillotine style with a pulley and a string to actuate it. Sometimes if the guillotine gets stuck the string will wrap the wrong way around the pulley so I need to check both limits while the motor is on.

I was having some issues:

  1. Getting the light setpoint correct
  2. Some random resets
  3. Some bouncing from the limit switches was stopping the door in the wrong spot. Unsure if this was mechanical bounce or electronic.

I added code to have short and long pushes on the button (used on board button for this test)

  1. Short push toggles the door state
  2. long push reads the LDR value and uses that as the trigger.


In a previous revision I polled the limit switches (readLimits function remains), but I tried to add interrupt based limits. From my testing, the interrupt never gets triggered. If I initialise the limitResult variable = 3, the loop works, thinking it has lowered the door. If I set it =0, then it tries to lower the door and never responds to the buttons (limit switches). Running the polling function in parallel shows the limits are changing and the MSP430 can read the change.

I tested the dual state button code from here (https://www.electro-tech-online.com/threads/dual-state-pushbutton-debounced-using-interrupts-for-arduino.147069/) which worked OK.

I then adapted this to have more states, and ability to handle two limit switches.


So the question is, what am I doing wrong that my interrupt function never triggers?

Is there a better way to do this?



coop20201103.ino Interrupts.ino morse.ino MoveDoor.ino Read.ino

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...