GPIO programming in KB9202C board

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

sureshkvl
Posts: 2
Joined: Sat Sep 04, 2010 2:21 pm

GPIO programming in KB9202C board

Mon Sep 06, 2010 3:51 pm

Hi ,
i require help to access the PC27/CP26/PC25/PC24 GPIO pins, present in the SV1 header.

I am able to access the inbuild LEDs using program given by the vendor. Those LEDs are connected in PC18, PC19,PC20. I have used the same method, but not able access the external GPIOs.

the code is below,

if ((memMapFile = open("/dev/mem", O_RDWR | O_SYNC)) < 0)
{
printf("ERROR: Unable to open /dev/mem\n");
return (DRIVER_NOT_FOUND);
}

at91SysCtrlr = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, memMapFile, (unsigned)AT91C_BASE_SYS);

if (at91SysCtrlr == MAP_FAILED)
{
printf("ERROR: Unable to mmap the system controller\n");
close (memMapFile);
memMapFile = -1;
return (MEMMAP_FAILED);
}

/* set LED signals for output */
/* set digital output ports init value = all on (active low) */
at91SysCtrlr->PIOC_CODR = GPIO_LED_MASK;
at91SysCtrlr->PIOC_PPUDR = GPIO_LED_MASK;
at91SysCtrlr->PIOC_PER = GPIO_LED_MASK;
at91SysCtrlr->PIOC_OER = GPIO_LED_MASK;


if ((memMapFile = open("/dev/mem", O_RDWR | O_SYNC)) < 0)
{
printf("ERROR: Unable to open /dev/mem\n");
return (DRIVER_NOT_FOUND);
}

at91SysCtrlr = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED, memMapFile, (unsigned)AT91C_BASE_SYS);

if (at91SysCtrlr == MAP_FAILED)
{
printf("ERROR: Unable to mmap the system controller\n");
close (memMapFile);
memMapFile = -1;
return (MEMMAP_FAILED);
}

/* set LED signals for output */
/* set digital output ports init value = all on (active low) */
at91SysCtrlr->PIOC_CODR = GPIO_LED_MASK;
at91SysCtrlr->PIOC_PPUDR = GPIO_LED_MASK;
at91SysCtrlr->PIOC_PER = GPIO_LED_MASK;
at91SysCtrlr->PIOC_OER = GPIO_LED_MASK;
}

at91SysCtrlr->PIOC_CODR=(ledSignalMapping[ledindex]);

inbuild LEDs are glowing, but the LEDs connected in the external GPIO pins are not glowing.
any help appriciated.
thanks
suresh

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 1 guest