I have more problems!!
So I got my Temp sensor fully working, without interrupts (interrupt to used as a display driver/refresher for the multiplexed 7 segment later on)
I even added a 100's column to display the temp to the top end of the range and also worked out how to interpet negative figures (invert + 1, anyone who has used one of these will probably know what i mean).
The 100's column digit also displays a - sign when the temp is in negative.
So I am reading and interpreting temperatures of the the DS18b20's full range.
So at the moment I have a routine that multiplexes the display in the normal program loop with some delays thrown in there so its visible.
The program executes as follows;
- Temperature is read from the Dallas DS18B20 and stored in the SCRATCHPAD_BYTE0 and SCRATCHPAD_BYTE1 GPR's
- Then the data is interpretted, determined whether neg or pos, shuffled around and stored in TEMPHI and TEMPLO GPRS as a positive number
- The data is then converted to binary (BIN_TO_DEC routine) with the result in the following format;
; HUNS GPR holds amount of hundreds (i.e. 0000 0010 = 2x100), TENS GPR holds amount of tens (i.e. 0000 0010 = 2x10) & ONES GPR holds amount of ones (i.e. 0000 0101 = 5x1)
- Then the HUNS and TENS are blanked if zero OR if negative temp a - sign is placed in the HUNS. (BLANK_IF_ZERO routine) *Note that the numebrs in the HUNS TENS ONES and TENTHS gpr's are jump pointers for the 2 tables.
- I then have a routine called LOAD_ARRANGEMENTS. what this does is call the table using the jump pointers in the HUNS TENS ONES and TENTHS, and returns and stores the 7 segment arrangement for the corresponding column in the HUNS_ARRANGEMENT, TENS_ARRANGEMENT, ONES_ARRANGEMENT and TENTHS_ARRANGEMENT so that these registers can be used later in the ISR so I wont need to call tables in the ISR.
- Then, temporarily, (while no ISR) i have a multiplex routine that moves xxx_ARRANGEMENT to PORTB and momentarily enables the appropriate segment display.
Then the whole program loops and it works perrrfectly.
So then I wanted to use interrupts to drive the multiplexed display.
I am using timer2 interrupts to interrupt the program.
I tried tweeking, (and It looks good to me) Mikes (Mike, K8LH) routine from above that uses Indirect Addressing to get the xxx_ARRNGEMENTS (HUNS, TENS....) from the RAM (they are in sequencial order starting at 0x20.
But it didn't work.
Now to back track, i commented out the tmr2 interrupt setup, and all the enable and disable GIE bits there were, plus i brought back my temporary multiplex routine and tried again.
and it still did weird things.
Now, at this stage, I have NOTHING that should be interrupting the program and making it jump the the intterrupt vector address but I know it is becasue I placed a goto instruction telling the program to goto the very bottom of the program where I have set some indictors to let me know if the program is there (simply lights up the 7 segment display). but when I comment out the rest of the ISR and leave the GOTO, it works.
It is like there is something in the ISR that make the program jump to the ISR because when the ISR's not there it works fine.
So here's the program (its to big to paste here)
PIC16F628A - DS18B20 Digital Thermometer
I've got the tmr2 comment out, and am using a temporary multiplex routine to display the temp.
It doesnt work but as soon as I coment out the ISR it works.
But I shouldn't have anything in the program that make it go to the ISR.
even if i stick a BCF INTCON,GIE at the top. same thing happens.
Any ideas?