Aichibo
Newbie level 2
Hey all,
I'm kinda new to all this and I've been referencing Kernighan and Ritchie's book on C programming while looking through the various posts on this forum to try and work out how to complete my task.
So far I've managed to:
Get LEDs to turn on via pointers to the ports, run these functions off variables, get it to check via bitwise whether certain levels are higher than set values to how many LEDs it turns on (battery meter) and then got it to poll a switch value and turn on the LEDs when the switch is depressed.
However, now I am trying to get the processor to go to sleep and then every 100ms or so wake up and poll the switch port to see if it is depressed. This is due to the board I'm working on doesn't have an availiable socket to the ports which allow direct access to the interrupts. So I'm doing it via a timer which brings the CPU to normal operations and then running my previous code which made the LEDs glow when the switch is depressed.
Obviously this will not be as responsive as having it looping and polling the switch but as its going to be a battery powered device, I thought that this would be a good work around.
The problem is.. I have no idea how to code the timer to run for a certain amount of time then firing an interrupt to bring the processor out of sleep before running my code.
If you require the rest of my code, please ask.
TL;DR: Noob doesn't know how to code.
Thanks in advance!
I'm kinda new to all this and I've been referencing Kernighan and Ritchie's book on C programming while looking through the various posts on this forum to try and work out how to complete my task.
So far I've managed to:
Get LEDs to turn on via pointers to the ports, run these functions off variables, get it to check via bitwise whether certain levels are higher than set values to how many LEDs it turns on (battery meter) and then got it to poll a switch value and turn on the LEDs when the switch is depressed.
However, now I am trying to get the processor to go to sleep and then every 100ms or so wake up and poll the switch port to see if it is depressed. This is due to the board I'm working on doesn't have an availiable socket to the ports which allow direct access to the interrupts. So I'm doing it via a timer which brings the CPU to normal operations and then running my previous code which made the LEDs glow when the switch is depressed.
Obviously this will not be as responsive as having it looping and polling the switch but as its going to be a battery powered device, I thought that this would be a good work around.
The problem is.. I have no idea how to code the timer to run for a certain amount of time then firing an interrupt to bring the processor out of sleep before running my code.
If you require the rest of my code, please ask.
TL;DR: Noob doesn't know how to code.
Thanks in advance!