i do not want to post the code; but i can email it to you. i'm using the basic interrupt routine (on interrupt goto handel)
i do not want to post the code; but i can email it to you. i'm using the basic interrupt routine (on interrupt goto handel)
Are you clearing "all" interrupt flags before exiting your interrupt handler?
Yes, but can i use a pause command in the interupt?
Code:Disable ' interrupt handler Handle: if RCIF = 1 then ' serial intterupt RCIF = 0 ' clearing interrupt flags IF OERR THEN ' Clear over-runs if OERR set CREN = 0 ' Disable USART receive CREN = 1 ' Re-enable USART receive ENDIF 'Serial commands. endif IF TMR0IF = 1 THEN 'RECEIVE all A/D value's TMR0IF = 0 gosub CoversionsAD gosub saftycontrol 'check al received value's ENDIF if TMR1IF = 1 then TMR1IF = 0 gosub PacketSend endif TimeOut: resume enable
Last edited by egberttheone; - 13th February 2006 at 19:14.
You can use all the pause statements you want inside a BASIC interrupt, however, I don't recommend you place gosubs in your interrupt handler.
This exits the interrupt handler, and if it lands in a sub routine where you are not disabling PBP's auto-insertion of interrupt checking stubs, then it's going to go totally nuts on you.
Place all of your routines inside the interrupt handler, or set/clear some type of flags to indicate the interrupt source, then return, then act on the other sub routines as needed.
Also note that RCIF can NOT be cleared with RCIF = 0. The only way to clear RCIF is to read the fifo USART buffer until it's empty. Trying to clear this flag like you are, you're leaving it set, and never clearing the USART interrupt flag bit.
ah! the gosubs seems to be the problem! but now I have the problem that the a/d conversion some times fluctuates(value's are not the same every querying + 1000 some times). Where can I begin to debug? Thx !
A/D readings will pretty much always fluctuate. A small RC filter on each A/D input may help. If not, you might consider putting the PIC to sleep prior to A/D readings to reduce in-circuit noise from the oscillator & internal switching.
If you think "code" may be causing the fluctuations, then simply strip down the program to nothing but reading & displaying A/D values. If it works smoothly, then take a hard look at the rest of your code.
Bookmarks