How to access the value of a digital input terminal?

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

cross mob
JoBr_1593366
Level 5
Level 5
100 sign-ins 50 questions asked 100 replies posted

I'm trying to edit an existing component to replace a hardware digital input pin with a digital input terminal, so I can control it from my schematic directly, rather than connecting it to a hardware GPIO. But how do I access the value of the terminal from inside the component? It doesn't have a read() function like a pin does? Do I need to connect it to a control register or something?  All it does is read a true or false value from the surrounding circuit.

It would be simpler if I didn't need the terminal at all. Is there a way to have a component get a truth value from the containing schematic/program other than using a terminal?  Maybe the component exposes a function that lets the containing project modify it's internal state?  But the opposite would be better: if the component could query the containing project's state.

0 Likes
1 Solution
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

Which existing component are you trying to modify?

Pin components in an existing component can be replaced with a terminal symbol on the schematic.  In this case, it is not available to get the status of these input pins and specify the logic level of these output pins.  You can add a Status Register component to the input terminal to get the status and a Control Register component to the output terminal to specify the logic level.

GS004830.png

Regards,

Noriaki

View solution in original post

6 Replies
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

Which existing component are you trying to modify?

Pin components in an existing component can be replaced with a terminal symbol on the schematic.  In this case, it is not available to get the status of these input pins and specify the logic level of these output pins.  You can add a Status Register component to the input terminal to get the status and a Control Register component to the output terminal to specify the logic level.

GS004830.png

Regards,

Noriaki

Ok.  Is there a programmatic way to communicate with a component that I'm not thinking of?  So a component can call a function internally that gets some state from the outside circuit that contains it?

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

JoBr,

You can use a buried Pin inside the component. You can find an example of the buried pin example here:

ButtonSw32: button switch debouncer component

Basically, drop a Pin into component schematic (name Pin1), and set Hardware connection to False.

Reading value of the pin:

result =`$INSTANCE_NAME`_Pin1_Read(),

where `$INSTANCE_NAME` is the name of your component.

It can be read directly from the main.c or wrapped into component's *.h and *.c files.

/odissey1

0 Likes

Basically, drop a Pin into component schematic, and set Hardware connection to False.

How do you do that?

0 Likes

JoBr,

You mentioned that there is existing component with schematic, which you would like to modify. So open that achematic, and drop a standard digital input Pin (a little square with green wire). Dbl-click it to open Settings an uncheck property hardware connection. The pin will look as a small square.

That's all. Now in the Design Wide Resources->Pins you can see this pin. And you can read this pin as shown in the previous message.

/odissey1

0 Likes

I think that's the opposite of what I want? The component already has a pin inside it that maps to an external GPIO in the DWR.  I want it to NOT connect to an external GPIO, so I'm not wasting pins.

I managed to turn it into a terminal with a Status Register so it can be routed internally instead, and that seems to be working well.

0 Likes