Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "address_mapping.h"
- unsigned int state;
- int countOnes (int n)
- {
- int count=0;
- if (n == 0){
- return 0;
- }
- while (n>0)
- {
- n = n & (n-1);
- count++;
- }
- return count;
- }
- int main() {
- *SWITCHES_CONTROL = 0xFFFF;
- *LED_CONTROL = 0x0;
- int ledCounter = 1;
- int temp;
- while (1 == 1) {
- countOnes(*SWITCHES_DATA);
- temp = countOnes(*SWITCHES_DATA);
- while(temp > 0){
- ledCounter = ledCounter*2;
- temp--;
- }
- ledCounter--;
- *LED_DATA = ledCounter;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement