Hi, I got a BBB.
I connected a LED to its GPIO1_16 pin, which I tried to turn on and off using the GPIO configuration in the code below. For some reason the LED does not turn ON. When I use the same GPIO pin, but using the Virtual File System code to turn on the LED, it works. Therefore I guess i'm missing something with the below code. Do you spot any problem? Thanks a lot. #define GPIO1_BASE 0x4804C000 // Start Address #define GPIO1_END 0x4804D000 // End Address #define GPIO1_SIZE GPIO_END - GPIO_BASE #define GPIO_OE 0x0134 // Offset #define GPIO_DATAOUT 0x013C // Offset #define GPIO1_16 16 int main(int argc, char** argv) { volatile unsigned int *reg_base, *reg_oe, *reg_out; unsigned int value; int fd; //open mem file for Read and Write fd = open("/dev/mem", O_RDWR); if (fd == -1) { perror("Unable to open /dev/mem"); exit(EXIT_FAILURE); } /* LED Setup and Turn-on */ reg_base = mmap(0, GPIO1_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd,GPIO_BASE ); //Set GPIO to Output reg_oe = (volatile unsigned int*)(reg_base + GPIO_OE); value = *(reg_oe); value &= ~(1 << GPIO1_16); *(reg_oe) = value; //turn on GPIO reg_out = (volatile unsigned int*)(GPIO1_16 + GPIO_DATAOUT); value = *(reg_out); value |= (1 << GPIO1_16); *(reg_out) = value; return 0; } -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.