element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Smarter Life
  • Challenges & Projects
  • Design Challenges
  • Smarter Life
  • More
  • Cancel
Smarter Life
Forum Need help with watchdog
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 4 replies
  • Subscribers 5 subscribers
  • Views 1624 views
  • Users 0 members are here
  • smarter_life
Related

Need help with watchdog

bose
bose over 11 years ago

Hello,

 

I have a question regarding the watchdog timer in PSoC 4.

As per the documentation there are three counters:

  • Counter 0 & Counter 1 = 16bit driven by ILO 32Khz and can be cascaded
  • Counter 2 = 32bit driven by ILO 32KHz

I wish to use the Counter 2 to generate a 2Second wake-up Interrupt from deep sleep for the PSoC4.

And Counter 1 + Counter 0 for the WDT Reset at 5Seconds.which would reset the microcontroller in case it fails to clear the counter 1 & counter 0.

 

However no where I could find any information on the cascade scheme of the counters.

 

Kindly help me out on this.

 

Warm Regards,

Abhijit

  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 11 years ago +1
    Abhijit, Watchdog is configured through a set of dedicated APIs in PSoC4. You can find more information on how to configure watchdog using these APIs from the PSoC Creator System Reference Guide, which…
  • bose
    bose over 11 years ago in reply to Former Member +1
    Hi, I am aware of the API. However I am not sure how the watchdog counters are arranged. The problem here is that as the document PSoC_4_Architecture_TRM_001-85634_0B document does not mention the ordering…
  • hlipka
    hlipka over 11 years ago +1
    You need the CySysWdtWriteMode() call. It configures the counters to either interrupt or reset mode. CySysWdtWriteCascade() is used to cascade the counters together. Use CySysWdtWriteToggleBit() to define…
  • Former Member
    Former Member over 11 years ago

    Abhijit,

     

    Watchdog is configured through a set of dedicated APIs in PSoC4. You can find more information on how to configure watchdog using these APIs from the PSoC Creator System Reference Guide, which is accessible from Help-> Documentation toolbar of Creator. I've attached a copy just in case.

     

    Specifically, you can use the CySysWdtWriteCascade() API for your requirement.

     

    Regards,

    Arvind

    Attachments:
    imagesystem_reference_guide.pdf
    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • bose
    bose over 11 years ago in reply to Former Member

    Hi,

     

    I am aware of the API. However I am not sure how the watchdog counters are arranged.

    The problem here is that as the document PSoC_4_Architecture_TRM_001-85634_0B document does not mention the ordering and interrupt order of the three counters and their combinations in a block diagram way.

    In my case, I wish to independently use the Counter 0 - Counter 1 for Reset purpose and Counter 2 for wake-up purpose.

    That's where I needed clarity.

    I have tried out the following configuration code but it does not work as expected.

    In this code I had used Counter 1(Lower order)+Counter 0(Higher Order) for 5second and Counter 2 to generate wake-up every 2seconds.

    #include <project.h>
    #include <cyPm.h>
    CY_ISR(Wakee)
    {
        
       CySysWdtUnlock();
        CySysWdtResetCounters(CY_SYS_WDT_COUNTER0_RESET|CY_SYS_WDT_COUNTER1_RESET|CY_SYS_WDT_COUNTER2_RESET);
        CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER0_INT);
        CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER1_INT);
        CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER2_INT);
        CySysWdtLock();
        CyIntClearPending(9);
    }
    int main()
    {
        CyIntSetVector(9, Wakee);
        CyIntEnable(9);
    
        CySysWdtWriteMode(CY_SYS_WDT_COUNTER0,CY_SYS_WDT_MODE_INT_RESET);
        CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0,0x7100); //5sec
        CySysWdtWriteClearOnMatch(CY_SYS_WDT_COUNTER0, 1u);
        CySysWdtWriteCascade(CY_SYS_WDT_CASCADE_01);
        CySysWdtWriteMode(CY_SYS_WDT_COUNTER1,CY_SYS_WDT_MODE_RESET);
        CySysWdtWriteMatch(CY_SYS_WDT_COUNTER1,0x0002); //5sec
        CySysWdtWriteClearOnMatch(CY_SYS_WDT_COUNTER1, 1u);
        CySysWdtWriteMatch(CY_SYS_WDT_COUNTER2,0x0FA00);   //2sec
        CySysWdtWriteMode(CY_SYS_WDT_COUNTER2,CY_SYS_WDT_MODE_INT);    
        CySysWdtWriteClearOnMatch(CY_SYS_WDT_COUNTER2, 1u);
        CySysWdtEnable(CY_SYS_WDT_COUNTER0_MASK|CY_SYS_WDT_COUNTER1_MASK|CY_SYS_WDT_COUNTER2_MASK);
        CySysWdtLock();
    
        CyGlobalIntEnable;
    
         while(1)
         {
              Pin_LED_Write(0);
              CyDelay(20);
              Pin_LED_Write(1);
              CySysPmDeepSleep();
         }
    }

    I have tried out several other combinations but nothing seams to work correctly.

     

    Kindly help me on this.

     

    Warm Regards,

    Abhijit

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • hlipka
    hlipka over 11 years ago

    You need the CySysWdtWriteMode() call. It configures the counters to either interrupt or reset mode.  CySysWdtWriteCascade() is used to cascade the counters together. Use  CySysWdtWriteToggleBit() to define the period for counter2 (can only be a power of 2).  CySysWdtWriteMatch(() is not supported for counter 2! Look at the function description in the System reference manual...

     

    On the interrupt of counter 2, you need to reset counters 0 and 1. (Maybe also toggle a LED in the ISR, to see whether it gets called at all - you should try to get that working properly first...)

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • jagir008
    jagir008 over 7 years ago in reply to hlipka

    Hendrik,

    Yes it is right CySysWdtWriteMatch(() is not supported for counter 2.

    but can you roughly give an algo for cascading two timers to get >= 5 sec watchdog interrupt interval, Because I also want to cascade two timers to achieve >= 5 seconds of watchdog interrupt interval.

    I agree with Abhijit that it is not described at any of document that in which sequence we use watchdog API to cascade two timers.

    Can we achieve this by using counter 2 (As counter 2 has a 32-bit period)?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube