We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi
i am using arm 9 board(samsung s3c2440), and i am doing the simple program to recognize user button from user led . actually there is no error in this program but this program is not working properly....." #include "def.h" #include "2440addr.h"
void delay(int x) { int i,j; for(i=0;i<=x;i++) { for(j=0;j<=x;j++) {}}
}
int main (void) { rGPGCON=0x000000; rGPGUP=0x000000; rGPBCON=0X0015400; rGPBUP=0x000000;
while(1) { while((rGPGDAT)&(0x0800)==0x0800) {rGPBDAT=~0x020;} while((rGPGDAT)&(0x080)==0x080) {rGPBDAT=~0x040;} while((rGPGDAT)&(0x040)==0x040) {rGPBDAT=~0x080;} while((rGPGDAT)&(0x020)==0x020) {rGPBDAT=~0x100;}
}" the problem is that all leds are recognizing with only one user button randomly. and no other buttons are working except 1st. help me what is the problem?
Error 1: You ignored the information how to post source code. Clearly visible directly above the input message box.
Error 2: You totally forgot comments in your code.
Error 3: You expect the readers to know how you have connected your processor, i.e. where you have buttons and where you have LEDs.
Error 4: You love magic constants in your code.
Error 5: You are playing with infinite loops without caring about how the code execution gets stuck there and during that time will not look at other buttons.
Error 6: You continue to assign for a LED as long as you see a button pressed - how many times do you think the processor will manage to see the button press before you finally release the button?
Error 7: You haven't considered how your code should be able to either toggle a LED, or perform a set or reset based on detected button state. Just assigning rGPBDAT = ~SOME_CONSTANT isn't managing that.
sorry for that . but this is a ready made board. and i have used "if" statement also but the same problem is coming(error 5,6).and these constants are codes to switch the each led. there are 4 leds connected with port B(high enable) at pin 5,6,7 and 8.port B is 11 bit port and user buttons(NO) are connected with port G at 0,3,5,6,7 and 11.
So - your problem should have been solved if you had worked through my list.
Have you considered maybe having code that can both turn on - and turn off - a LED? Code that can only turn on - or only turn off - a LED is rather boring.