[PIC] ISR Code Problem.

Status
Not open for further replies.

JAI PRAKASH LAMBA

Newbie level 5
Joined
Nov 12, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
81
Hello All,

Below i have given all the details related to my problem but not able to solve it i think problem is in isr code. If anyone one have any idea let me know , also attached the code below in text form i am using a pic16f676 for which i am using internal oscillator for time calculation but it is not stable i have used 4 mhz osc but getting not getting the correct calculated time using isr


Then i try using a same pic(mcu) for which i am using external oscillator for time calculation but it is also not stable i have used 8 mhz osc and also 32.768.khz external osc also but not getting the correct calculated time.

i will brief about that in my code i am calculating the total run time of motor when it is running otherwise not, depending on the hours calculated i have to turn ON three led's with buzzer but it does not work when i try it with internal oscillator of pic16f676 then i also tried external oscillators i.e 8 Mhz and 32.768Khz but the problem remains same i am not getting the correct o/p i.e led's are not turning ON at the right time instead of that it will turn ON at 285 hrs 5 mins and some times 285 hrs 5mins 45 sec means oscillator is of varying nature, same i tried to turn on the led's at the 1 hrs interval then in first hour one led is ON but at 1 hr 20 sec, in 2nd hr it turn ON at 2hrs 40 sec ..... then 3 hrs 1 min .... then 4 hrs 1 min 15 sec i have observed that every hour 20 sec delay is added in my time calculation every hour ----> in this case i have forcefully call my led turn ON function( EOL func ) in which i observed that scenario.

but when i call my EOL function from my pump_control_module then i delay addition is more and more delay is added every hour

when i am not getting the correct output then i call my EOL_module function from isr this will some how reduce my problem not all. It will not give problem if it works for small time measurement but for time calculation over 600 hrs it effects my project severly
 

Attachments

  • Defines.txt
    2.4 KB · Views: 60
  • Init.txt
    1.8 KB · Views: 79
  • interrupt routine.txt
    5.9 KB · Views: 67
  • main.txt
    15 KB · Views: 56

Put the whole code in the isr in a function and call this function from

Code C - [expand]
1
while(1)

. Before doing that you have to use a flag to execute this function. Set this flag in ISR is and test for this flag in

Code C - [expand]
1
while(1)

. If true call the function which contains all the code in ISR.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…