i using bit banding set , clear gpio6[1] of lpc1857 using keil.
the mapping address in bit band region set gpio6[1] comes 0x43ec4304
the mapping address in bit band region clear gpio6[1] comes 0x43ec5384
the gpio gets set not cleared.
when checked on debugger, observed mapping address clear gpio6[1] getting set 0x43ec5000. gpio not clear.
can please understand why happening ? , how can resolve mapping address setting wrong address @ run time ?
following code snippet:
/*in "main.c"*/ int main() { ... //system initialization ... //gpio init ... toggle_peri(); } /*in "peri.c"*/ /* bit band peripheral definitions */ #define bitband_peri_ref 0x40000000 //start address of peripherals #define bitband_peri_base 0x42000000 //start address of peripheral bit band alias region /* basic bit band function definition */ #define bitband_peri(a,b) ((bitband_peri_base + ((a-bitband_peri_ref)*(0x20)) + (b*(0x04)))) // convert gpio address #define bitband_peri_setclearbit(a,b) ((*(volatile uint32_t *) (bitband_peri(a,b))) = 1) /*note: base address of gpio = 0x400f 4000*/ #define peri_gpio_address_s 0x400f6218 //for gpio6[1] set #define peri_gpio_address_c 0x400f629c //for gpio6[1] clear #define peri_gpio_bit 1 ... ... ... ... void toggle_peri(void) { bitband_peri_setclearbit(peri_gpio_address_s,peri_gpio_bit); //set pin delay(0xffff); bitband_peri_setclearbit(peri_gpio_address_c,peri_gpio_bit); //clear pin delay(0xffff); }
thanks.
Comments
Post a Comment