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
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Pic Microcontrollers Forum PIC18f2423 is strucking
  • 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 Suggested Answer
  • Replies 2 replies
  • Answers 1 answer
  • Subscribers 193 subscribers
  • Views 416 views
  • Users 0 members are here
  • strucks
  • pic18f2423
  • microcontroller
Related

PIC18f2423 is strucking

Former Member
Former Member over 11 years ago

Dear All,

 

I'm doing Offline Datalogger using PIC18f2423.  At an subsequent interval, microcontroller reads Date and time from DS1307RTC and Energy meter data via 485IC (Modbus Protocol).  Store these results in EEPROM(24512). Whenever I require, I interface my kit with PC, and collects the stored data.  All are working good and I can retrieve correct data also.  But rarely and randomly while reading RTC and Energy data, somewhere my microcontroller strucks and after some time (may few minutes), it will continue it's work again.  If any body has any idea about this, please help.

 

This is my first post.  If anything wrong in this, or any information I missed to write, or if I post this in wrong place, kindly bear.  

 

Thanks.

  • Sign in to reply
  • Cancel
  • MicrochipRTCfr
    0 MicrochipRTCfr over 11 years ago

    Hi,

     

    How are you developing ?

    Which development tool do you use (Pickit3, ICD3,...) ?

    Which compiler do you use : C18, XC8 ?

     

    If it is stuck for some time, it probably means the CPU is waiting for some event to happen (I2C ? SPI?) or some counter to reach a certain value.

     

    If you use debugger, you can put breakpoints.

     

    What you can also do if you suspect that it remains stuck somewhere you can add timeouts to each while loop reading sensor or doing some action.

    This is widly used to make robust SW to avoid it get stuck for ever

    Example:

     

    [code]

    while ( !ready && !timeout)

         counter++;

         if (counter > max)     

              timeout = 1;

     

    if (timeout == 1)

    {

    // if we enter here there an been an error. Send error message

    }

    [/code]

     

    In this pseudo code ready is a flag which is set to 1 when data is read from external sensor. It should go to 1 before counter > max

    max is a timeout delay or value

     

    Of course this is only a concept. you can implement above one with interrupts (timeout interrupt) to make SW more efficient.

     

    Can you please explain how many interrupts you use ?

    Can you show your SW interrupt ?

     

    regards

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to MicrochipRTCfr

    Thanks for the reply.  I develop my code in MPLAB IDE and used CCS compiler.

     

    "If it is stuck for some time, it probably means the CPU is waiting for some event to happen (I2C ? SPI?) or some counter to reach a certain value." - Your words may be right.  I also have that doubt. 

     

    I have included DS1307.C for RTC and modbus.c for modbus communications.  Other than that I did not use any other interrupts and sleep mode.  I can understand the possibility you are telling.  But I do not know the way to define software interrupt.  Kindly guide me.

     

    Thanks & Regards.

    • 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