Hi all,
Can someone explain the following code,kindly explain line by line.Since i'm new to hardware programming.
/* Initialize timer for GPIO toggling timing */ enable_timer( 0 );
counter = 0; FIO2SET = 1 << counter; // #define FIO2SET (*(volatile unsigned long *)(FIO_BASE_ADDR + 0x58)) while ( 1 ) { if ( timer0_counter >= (0x20 * counter) ) { FIO2SET = 1 << counter; counter++; if ( counter > 8 ) { counter = 0; timer0_counter = 0; FIO2CLR = 0x000000FF; } } } return 0; }
Chethan
Isn't it better that _you_ start by investing of _your_ time by: 1) Figure out how to correctly post source code on this site. 2) Tell _us_ what part of the code you don't understand. 3) Tell _us_ which documents you have retrieved and studied to try to figure out the meaning of the code.
Hello
Sry for the inconvenience,to enable timer the logic of the code i'm not getting. And these are sample codes which had been downloaded from NXP website :
www.lpcware.com/.../sample-code-bundle-lpc23xxlpc24xx-peripherals-using-keils-μvision
/* Initialize timer for GPIO toggling timing */
enable_timer( 0 ); counter = 0; FIO2SET = 1 << counter; //#define FIO2SET (*(volatile unsigned long *)(FIO_BASE_ADDR + 0x58)) while ( 1 ) { if ( timer0_counter >= (0x20 * counter) ) { FIO2SET = 1 << counter; counter++; if ( counter > 8 ) { counter = 0; timer0_counter = 0; FIO2CLR = 0x000000FF; #define FIO2CLR (*(volatile unsigned long *)(FIO_BASE_ADDR + 0x5C)) } } } return 0; }
Well it really doesn't show much in the way of timer initialization code, now does it?
The function of the code, from a cursory analysis, would appear to enable 8 GPIO bits in sequence, with a delay multiple of 32 ticks between each, and when all bits are enabled, it then clears them and starts over.
But "sample code" is useless if you haven't also studied the chip documentation.
Have you studied the chip documentation ?.
"There are also many other resources for getting you up and running with your new hardware"
http://www.lpcware.com/
So - have you studied those resources?
View all questions in Keil forum