element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Embedded Forum exception handling by micro controller
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 5 replies
  • Subscribers 461 subscribers
  • Views 581 views
  • Users 0 members are here
  • handling
  • errors
  • exception
Related

exception handling by micro controller

dr.akshay_1980@yahoo.com
dr.akshay_1980@yahoo.com over 10 years ago

I want to know if there is any feasible method for the micro controller to handle divide by zero or any other exception encountered while doing mathematical calculations or solving complex algos.. I don't want my controller board to be reset after encountering this or I want to use watch dog timer in order to overcome this.

 

My C code routine for the micro controller is not capable of handling this real time problem while doing some complex calculations..What should I do.??????

 

Thanks,

Akshay

  • Sign in to reply
  • Cancel

Top Replies

  • michaelkellett
    michaelkellett over 10 years ago in reply to dr.akshay_1980@yahoo.com +2
    8051 processors don't support exceptions (you probably know that). If I were you I would move over to using CortexM4 which does offer a divide by zero exception and much better debugging than any 8051…
  • michaelkellett
    0 michaelkellett over 10 years ago

    You might start by telling us which micro controller you are using .

     

    If it has no hardware detection of such problems then you have no alternative but to design the solution into your software.

     

    In 40 years (approx) of micro controller design work I have never had a case where this could not be done.

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • dr.akshay_1980@yahoo.com
    0 dr.akshay_1980@yahoo.com over 10 years ago in reply to michaelkellett

    I have just started experimenting my algorithm with low end controller 8051 series. The board while running encounters 0 (zero) as denominator while solving the complex mathematical calculation and thus freezes up in the middle and getting stuck somewhere. I was trying to use 'TrY and Catch' situation when handling this type of exception but my compiler doesn't allow me to use or I don't know the way to implement this in embedded as its somewhat OOP approach toward embedded systems.

     

    Eventually  I will be porting my code to high end controllers such as ARM / freescale imx

    I am using P89V51RD2 series from philips and other is C8051F020 from silicon labs..

     

    Do add me in your contact list...

     

    Bye,

    cheers

    Akshay

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • dr.akshay_1980@yahoo.com
    0 dr.akshay_1980@yahoo.com over 10 years ago in reply to dr.akshay_1980@yahoo.com

    P.S.

    other way around I am trying to use watch dog timer when my board encounters exception and it will get reset but I don't wanna  reset my board..

     

     

    Bye,

    Akshay

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 10 years ago in reply to dr.akshay_1980@yahoo.com

    8051 processors don't support exceptions (you probably know that).

     

    If I were you I would move over to using CortexM4 which does offer  a divide by zero exception and much better debugging than any 8051 parts.

     

    (It might be a  good idea to debug your algorithm more before writing any code so that you can see where errors can occur.)

     

    You can buy a board with an STM32F4xx on it for less than £10 and use the Keil/ARM free tools until the code is greater than 32k.

     

    MK

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • clem57
    0 clem57 over 10 years ago in reply to dr.akshay_1980@yahoo.com

    @Akshay Sharma

        You may have solved this! May I suggest if the denominator is float, add a small float value to bottom to avoid divide by zero if you do not want to test for it. This will add a slight skew to the results that may be tolerable.

     

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • 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