2 Replies Latest reply on Sep 18, 2017 8:49 AM by user_463759797

    Can PSoC handle try-catch exceptions?

    user_463759797

      I am trying to use the Segger SDCard system licensed to Cypress without source code.  It generally works.

       

      Our processing has to be bullet proof.  We can't crash due to third party code.

       

      The Segger code is licensed "as is."  It has an exception in it where it ends up in the unhandled exception vector if you try to get a volume name when an sd card is removed.  Without source code, I don't know how to patch it to fix this issue.

       

      I can call my own function for the exception, but without exception handling, I'm unsure what that buys me.  (in CyApiCallbacks.h :

      #define CY_BOOT_INT_DEFAULT_HANDLER_EXCEPTION_ENTRY_CALLBACK  

          extern void CyBoot_IntDefaultHandler_Exception_EntryCallback();

      )

       

       

      This can happen at any time due to vibration, bad contacts, or just dumb luck.   When it happens, the psoc is spinning in its unhandled interrupt loop. I could do a watchdog timer, but this seems too much work trying to determine if this is a cold power on boot, or a dirty watchdog boot where I need to preserve system variables. 

       

      I tried try/catch, setjmp,longjump, etc.  Unfortunately, try-catch appears to be unavailable.  setjmp.h is available, but longjump is a function not in the library.

       

      I tried removing the -fno-exceptions flag, but that did not help.

       

        I'm open to suggestions.  There is a third party open source code base out there, but its code-page stuff on it is problematic during our testing, so short file names have to be used.  Bummer.    However, it gracefully recovers from uninstalled sdcards, just like emFile *should* do, but does not.

       

      Any suggestions. Can I use try-catch?  If so, how? 

       

        Can I use setjmp, longjump?  if so, how?

       

      Or, any suggestions on easily preserving state across boot with temporary storage that is not easily replicated randomly during power up?

        • 1. Re: Can PSoC handle try-catch exceptions?
          user_1377889

          Try/catch and longjump are not related to PSoCs but to the C compiler you use. On the other hand you are free to capture any of the system interrupts as NMI or the int default handler and to implement some fixups.

           

          Bob

          • 2. Re: Can PSoC handle try-catch exceptions?
            user_463759797

            I received an email from Cypress that indicated I could reply to it to answer your post.  That failed.

             

            Regardless, I was hoping in what in the past was called a "BSP" (Board Support Package) that someone (Cypress, or anyone else) had supported try/catch in the compiler package that comes with PSoC creator.  Embedded Ninja and others indicate that work has not yet been done.  So far, no one has reported getting exception handling to work in the PSoC.

             

            Since my timeframe won't stretch to including updating the libraries for PSoC, I went the route of the elm-chan library.  Unlike the Cypress licensed Segger library, it does not crash when a card is removed during an attempt to read or write.  Unlike the Cypress licensed Segger library, you have access to the source code.

             

            So, for now, I don't need exception handling, and for now my problem is solved.  Yes, the question was answered.   But, sorry, is a disappointing answer.

             

            Thanks!

            1 of 1 people found this helpful