- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use CyPins_ReadPin() API to read the pin value. Refer to the "Per-Pin APIs" section in pins datasheet for more information
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use CyPins_ReadPin() API to read the pin value. Refer to the "Per-Pin APIs" section in pins datasheet for more information
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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();
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.