This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Raw GPIO output without using API Functions?

Probably frowned upon but like being able to work from raw datasheet, so I know that I can. So given that the datasheet would suggest that changing a GPIO pin to be an output is as simple as setting a bit, as a specific address, to 1. So I would expect the code:

int main(int argc, char **argv)
{
    uint32_t *p0_outset = (uint32_t *)0x50000508;
    uint32_t *p0_dirset = (uint32_t *)0x50000518;

    *p0_dirset |= 0x01 << 17;
    *p0_dirset |= 0x01 << 18;

    *p0_outset |= 0x01 << 17;
    while (1) {
    }
}

to illuminate the LED on pin P0.18, as the uC is on the low side of the LED. Either that or the LED on pin P0.17 to light. As it is neither LED lights and I'm confused as to why. The GPIO section of the datasheet doesn't mention having to specifically enable that Peripheral?

Parents Reply Children
No Data
Related