You are here

Pointer to io port? | Cypress Semiconductor

Pointer to io port?

Summary: 1 Reply, Latest post by Bob Marlowe on 22 Sep 2016 01:35 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
Christopher Curry's picture
1 post

Given that GPIOs are defined in PSoCGPIOINT.h as, e.g.:

#pragma ioport LED0_Data_ADDR:    0x0
BYTE           LED0_Data_ADDR;
#define LED0_MASK 0x2


I tried doing something like this in my code:


void SetLED(BYTE *address, BYTE mask)
    *address |= mask;



That compiled fine, but did not have any effect. It seems like the variables with #pragma ioport can't be referenced and dereferenced like that.

I can't find any in-depth information about #pragma ioport and I/O memory. Is there any way I can qualify pointers to work as intended? Or do pointers to io memory not work in this compiler?


user_1377889's picture
10688 posts

Welcome in the forum, Christopher!

Use pointers to functions instead. You can place some LED components into your design and use an array of pointers to that functions to control the LEDs, See here on how2

As a tip: Change to PSoC4. With debugging capabilities you can get a prototyping kit for few money.



Log in to post new comments.