Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * EE3173 Lab 3
- * Mark Furland
- * 2015-02-06
- **/
- #include <alt_types.h>
- void main(){
- alt_32 count = 0;
- alt_32 switchHist = 0;
- alt_32 buttonHist = 0;
- alt_32 delay = 0;
- volatile alt_32* display = 0x11050;
- volatile alt_32* switches = 0x11030;
- volatile alt_32* buttons = 0x11040;
- display[1] = 0xFFFFFFFF;//Set display direction to output
- for(;;){
- //If a switch goes high, it will be marked here.
- switchHist |= switches[0];
- if(switchHist != switches[0]){
- //A switch has gone low
- //This will miss multiple switches at the same time,
- //but I think this is acceptable?
- count++;
- switchHist = switches[0];
- }
- buttonHist |= buttons[0];
- if(buttonHist != buttons[0]){
- //A button is pressed
- count++;
- buttonHist = buttons[0];
- }
- //Set display to show count
- display[0] = count;
- for(delay=0;delay<1001;delay++) ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement