Writing to Digital outputs as bus

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaHu_285096
Level 5
Level 5
10 likes received 250 replies posted 100 replies posted

Hi,

I have 8 digital outputs that are on various pins of the 5LP that I want to control as a port using an 8-bit variable in code.

I created a digital output pin then then set number of pins to 8. I named the port "POWER"

Next I selected "Display as Bus" mapping.

Then I went to "pins" tab and set the pin designation.

I am having trouble setting the value of "PORT" in code.

The intellisense in PSOC creator shows "POWER_0, POWER_1 etc but I cannot work out correct syntax to do equivalent of POWER_Write(23) for instance.

Have I set this up wrong or simply not using corect syntax?

Thanks

0 Likes
1 Solution
BiBi_1928986
Level 7
Level 7
First comment on blog 500 replies posted 250 replies posted

Hello DaHu.

The example by Moto is perfect when you have an entire 8-bit port available.

When you have random GPIO's from several ports, you can use the Control_Reg component.  Now you can connect just about any GPIO output pin to the Control Reg output signal.

To write to this component is very simple.

Control_Reg_1_Write(i);    /* where i is uint8 */

pastedImage_0.png

This is not a bidirectional solution.  It is for writing only to the GPIO's.

Good luck with your project.

View solution in original post

3 Replies