How to receive the signal press button SW1 on LauchPad Stellaris?
As we press sw1 button, the red LED turn on
(do not use interrupts, use the loop to receive signals)
Help me ......
Regards!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
First try to run, then try to read, understand the source code of the example qs-rgb. It contain the answer to your question. You must observe the declaration: #include drivers/buttons.h - then go to that folder and you will find the file "buttons.c" - inside is the function unsigned char ButtonsPoll(unsigned char *pucDelta, unsigned char *pucRawState) which is the solution. Enjoy! (and don't take as granted, try to read, understand, and after reflection, experiment).
Petrei
Hi,
A switch is a mechanical device and combining with some electricity lead to the phenomenon called "bouncing" - i.e. mechanical contacts are not stable for some time - usually in the range of several milliseconds - so to overcome this a technique called "de-bouncing" is applied - same does that function - and return in a byte the status of those switches. All you need to do is: a) call that function periodically to catch up the changes and b) identify what bit (i.e. what bit represent your pin connected to the switch ) was changed. Run the example and put a breakpoint inside that function, near the end and see how it works.
Petrei
Hi,
In the example qs-rgb file qs-rgb.c, function SysTickInthandler() calls :
g_sAppState.ulButtons = ButtonsPoll(0,0);
This is the function mentioned in a previous post. If you don't want it inside an interrupt, then you can use it inside while(1) loop in main, but the best place is within interrupt, otherwise it may be affected by the rest of main code.
Petrei