Reading a Port Value

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

cross mob
Anonymous
Not applicable

 hi ,

   

      How can we Read the status Of a particular pin , how do we do this on firmware. The below schematic is i am comparing input voltage to pin with Vdac, if it exceeds comparator will generate a logic 1 at Pin 2 , if pin2 = logic 1  the ADC should stop.so how can we read the status of pin2 in firmware.

   

Thanks

   

 

   

   

0 Likes
1 Solution
Anonymous
Not applicable

 Use CyPins_ReadPin() API to read the pin value. Refer to the "Per-Pin APIs" section in pins datasheet for more information

View solution in original post

0 Likes
12 Replies
Anonymous
Not applicable

 Use CyPins_ReadPin() API to read the pin value. Refer to the "Per-Pin APIs" section in pins datasheet for more information

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi ,

   

     I thank u for your reply sir, here i am pasting the code and schematic, i am able to read the value from port , but here i didnt understand some of things.

   

1) from the Schematic , ADC should start convert if the Comparator2 value goes high, thats working but after started converting if comparator 1 goes high ADC should stop converting and LCD should clear display, but both are  not happening.

   

here is my code

   

-----------------------------------

   

void main()
{
    uint16 output;
    uint8 Values1;
/* Start the components */
   
    LCD_Start();
   
    VDAC8_1_Start();
   
    Comp_1_Start( );
   
    VDAC8_2_Start();
   
    Comp_2_Start( );
   
    Comp_2_SetSpeed(Comp_2_HIGHSPEED);
   
    /* Set high speed mode */
    Comp_1_SetSpeed(Comp_1_HIGHSPEED);
   
    ADC_DelSig_1_Start();
   
//    /* Start the ADC conversion */

   
    /* Display the value of ADC output on LCD */
    LCD_Position(0, 0);
    LCD_PrintString("ADC_Output");
   
    for(;;)
    {
       
         
        if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_WAIT_FOR_RESULT))
        {
            output = ADC_DelSig_1_GetResult16();
            LCD_Position(1, 0);
            LCD_PrintInt16(output);   
            Values1 =CyPins_ReadPin(CYREG_PRT12_PC2);
            if(Values1==1)
             {
              ADC_DelSig_1_Stop();
              LCD_ClearDisplay();
         
             }
        }
    }
}
 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Is your Comp 1 output connected to Port12 pin or Port 1 pin or Port 2 pin ?

   

Port12 is legit, if thats what you are using.

   

 

   

You are reading the output register for the port, should you not be reading -

   

 

   

   

 

   

 

   

If HW is designed to only supply ADC values > Vx1, and stop supplying values if

   

> Vx2, why not let adc run continuously, eliminate both comparators, and do these

   

tests in code ?

   

 

   

Regards, Dana.

lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi dana,

   

i am uploading the bundle.

0 Likes
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

   

 CyPins_ReadPin(CYREG_PRT6_PC2)  = 010H  (not 1) 

   

And what you don't like this option.
if (Comp_1_GetCompare())

   

Interesting information
Writing to a PSoC3 GPIO – Various options
http://www.cypress.com/?id=2314&StartRow=26&PageNum=6

EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

CyPins_ReadPin(CYREG_PRT6_PC2)  = 010H  (not 1) 

   

And what you don't like this option.
if (Comp_1_GetCompare())

   

Interesting information
Writing to a PSoC3 GPIO – Various options
http://www.cypress.com/?id=2314&StartRow=26&PageNum=6

   


 

ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

This might help as well -

   

 

   

http://www.cypress.com/?rID=57571

   

 

   

Regards, Dana.

ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

What may help is for you to describe why you want to start A/D at some

   

threshold, and stop it at another ? What is it you are trying to accomplish

   

with the design you posted ?

   

 

   

Regards, Dana.

Anonymous
Not applicable

Hi dana,

   

              how to start an ADC if input to is greater than 30 mv and how to stop it if its input reaches 4 v in firmware.I did this logic with comparators, but can we accomplish with code.

   

Thanks

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Let A/D run continuously, and test it for both conditions with flags

   

for each condition. So set a flag, call it "lowtrip", if > 30 mV, and

   

another if > 4V, calling it "high trip". Then use flag status to do what-

   

ever it is you are doing when these conditions are met.

   

 

   

Your may code to be a little more sophisticated, use averaged values

   

for tests (to reject noise), and/or use hysterisis for setting/clearing the flags............

   

 

   

Regards, Dana.

lock attach
Attachments are accessible only for community members.
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received


I probably would have done so. ( for CY8CKIT - 030 PSoC3)
Only it is not clear what it is.....

lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Attached is a solution w/o using VDACs and Comparators. The A/D reads the

   

pot on the -030 board, and you must jumper the hole next to LED1 to P12_2.

   

 

   

If you are a student I would ask you to continue on your design, as that will work,

   

with some changes/coding. In other words do not submit this design for student work,

   

you would not be doing yourself a good deed.

   

 

   

Regards, Dana.