- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am fairly new to watchdog and brownout detection. I have a prototype project running on a PSoC 4, and in the case of a brown out I have to be able to respond in the following way:
Input voltage drops under 3 V -->
Send 'turn off' command to appropiat chip -->
Wait ~3 seconds before checking that the input voltage has stabalized at >3 V-->
If the input voltage is still < 3 V wait for another ~3 seconds -->
Else if input voltage > 3V reset PSoC board
From what i can see I should be able to use CySysLvdEnable(CY_LVD_TRESHOLD_3_00_V) to detect the input voltage drop. However it does not seem to reset as expected. Could someone nudge me in the right way of how to implement the above flow?
Any help is greatly appreciated.
All the Best,
Kat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From the TRM -
- 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
Thank you for getting back to me Dana. It does not seem to give me.
I had implemented a reset cause check:
uint8 res_cause;
res_cause = *(reg32 *)CYREG_RES_CAUSE;
if(res_cause !=0){
//turn led 1 on}
else{
//turn led 2 on}
however, the board always indicates res_cause == 0 i.e. that the board was power cycled or XRES.
I tried a different approach
I added the GlobalSignal component set to PWRInt, with the interrupt LVD_ISR.
In the code I added the following:
static volatile CYBIT isr_lvd_flag = 0;
CY_ISR(LVD_ISR){
isr_lvd_flag = 1;
}
int main{
...
CySysLvdEnable(CY_LVD_TRESHOLD_3_00_V);
for(;;){
if(isr_lvd_flag){
// perform desired action and reset interrupt
isr_lvd_flag = 0;
}
..
}
}
However, the lvd interrupt does not seem to be called. Any idea as to why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apologise for the writing in the previous post - hope you got the gist of it though:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Look in the register TRM, I think the reg you are testing for LVD not
the right one ?
- 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
If you do a batch "find" on "LVD" then you will see applicable defines.
This is the one I found for LVD generated interrupt - CY_SYS_LVD_INT
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Dana.
To find the cause of the reset I can simply use the function:
CySysLvdGetInterruptSource();
However, I still need to find a way to take action when LVD is detected. I have attempted to do this by:
1) Implemented the Generate Signal component - Power System Interrupt
Output of component connected to isr component named LVD_ISR
2) In main() enabled LVD: CySysLvdEnable(CY_LVD_THRESHOLD_4_50_V);
3) Created Interrupt action:
static volatile CYBIT isr_lvd_flag = 0;
CY_ISR(LVD_ISR){
isr_lvd_flag = 1;
}
4) In main() I deal with the interrupt:
for(;;)
{ ...
if(isr_lvd_flag){
// action
}
...
However, even if I bring the supplied voltage down to 2 V the interrupt action does not happen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have -
1) Enabled global interrupts CyGlobalIntEnable;
2) Started the ISR component
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for not specifing, yes they are both included in my Init() function called as soon as main() is entered
void Init(){
system_on = ON;
// Enable global interrupts
CyGlobalIntEnable;
// PWM Tri-Colour LED
Clock_PWM_Start();
PWM_RED_Start();
PWM_GREEN_Start();
PWM_BLUE_Start();
// Enable LVD Interrupt
LVD_ISR_Start();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And you placed this on schematic -
- 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
Please note that LVD_Start(); had been commented out in the zipped file - this was just after testing different possible solutions. It didn't work with it in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The line no. 70 was commented out, it contained
LVD_ISR_Start();
which I replaced with
LVD_ISR_StartEx(LVD_ISR);
Did you have got something similar in your original code?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes - i have tried with both
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just for additional information; I am programming this to the PSoC4 CY8CKIT-42.
To test the conditions i am powering the board via the micro usb input with a voltage generator intiially set to 3.3V. I then slowly decrease the voltage down to approx 2.5V - nothing happens. However, if i press SW1 (XRES) at this point the LED is RED after the reset indicating the LVD has been senced. If I bring the power back to 3.3V the LED stays RED until I I press SW1 again.This time it senses the voltage is above the LVD treshold of 2.9 V and hence goes back to being GREEN.
Also, if I turn the power off and on again at the voltage generator when at 3.3V the LED is RED after the power cycle.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do not have a supply with varying output, so I cannot test your program in real.
What I am concerned of is the following:
The interrupt is connected to the signal as "level" which might cause the handler to stall because it is called over and over since the voltage stays low. The main-program is not executed anymore in this case.
Did you try to set a breakpoint within the handler?
I would suggest you to create a MyCase at Cypress: Top of this page->Support&Community->Technical Support->Create a Mycase and submit them your example with the corrected Isr_StartEx() call since that is in your submitted project the only way that the interrupt may work at all. Additionally supply a link to this thread, so they can see what already was tried and suggested.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The schematic I find tough to follow but is 5LP interfering with PSOC 4
operation during LVD ? You might wnat to look at PSOC 4 <> 5LP pins
to see if 5LP sees the LVD and resets the PSOC 4 ?
Quick check is 5LP Vdd tracking PSOC 4 ?
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob, simple way of getting a controlable power supply is use PSOC,
just drive ref leg of LDO with VDAC. Using wavedac create a ramped
supply for testing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the interrupt set to level was one of my desperat attempts to see if something like that was the cause of the error.
I have however got response from Cypress giving me code to test, which works!! (Allthough every now and then it seems to get slightly confused). They seem to be doing exactly the same as me, yet their code works and mine don't.
I will keep looking at this and let you know what i find.