Psoc designer

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

cross mob
Anonymous
Not applicable

Hello all,

I'm trying to turn the the ports of my psoc device by reading from an input from a raspberry pi  2 on port 3 , Ive configured all port drives to be in strong mode

if (PRT3DR & 0x0f ) // if high input from outside

{

PRT5DR=0xff;

PRT1DR=0xff;

}

else if (PRT3DR & 0x00 )// if low input

{

PRT5DR=0x00;

PRT1DR=0x00;

}

Is this correct ?

0 Likes
5 Replies
Roy_Liu
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 10 questions asked

The line below looks not good, as anything make an "&" with 0x00, the result will be 0.

"else if (PRT3DR & 0x00 )// if low input"

AN2094 - PSoC® 1 - Getting Started with GPIO is a good reference for how to use PSoC1 GPIO.

Roy Liu
0 Likes
SampathS_11
Moderator
Moderator
Moderator
250 sign-ins 250 solutions authored 5 questions asked

If you are reading from Raspberry Pi, and using GPIOs configured as strong drive, you are connecting two outputs together. This may cause either one or both of the GPIOs to fail, if they output opposite logic.

0 Likes
Anonymous
Not applicable

Sir, So how should I configure the the GPIOs for my project as High? or some other way?  

0 Likes
Anonymous
Not applicable

CODESNIP1.JPG

CODESNIP2.JPG

Sir, this is what I need to implement On the transmitter side i will send either 4 or 6 packets depending whether port 3 is receiving 5v or 0v from the raspberry pi. And depending on this on receiver side i will turn my Leds On or OFF     

0 Likes

You will have to configure the GPIO as High Z Analog.

If you have the input at Port 3, bit 0, use the following code

if (PRT3DR & 0x01)

{

     MAX_TX_PACKETS = 4;

}

else

{

     MAX_TX_PACKETS = 6;

}

If you have the input at Port 3 bit 4 the if condition would be

PRT3DR & 0x10

0 Likes