I'm very new to this pic and programing all together and i need some help. Can some one help me setting up my internal clock on my 16f887 chip.
I'm very new to this pic and programing all together and i need some help. Can some one help me setting up my internal clock on my 16f887 chip.
This is a good place to start reading to find out how to setup fuses.
http://www.picbasic.co.uk/forum/showthread.php?t=543
Now this is what you need to have in your code. This chip defaults to 4 Mhz
Code:@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF DEFINE OSC 4
Dave
Always wear safety glasses while programming.
I'm using the 16F887 pic chip and I'm using interrupts for multiplexing. I'm trying to get correct timing for pauses by using a FOR loop, but every time the program does an interrupt, it has a 2500uS pause each time. Is there a way to get the timining to one second?
You will need to show us your code so we can help you figure out what you are doing wrong.
Dave
Always wear safety glasses while programming.
Code:digit1 var portd.0 digit2 var portd.1 digit3 var portd.2 digit4 var portd.3 digit5 var portd.4 digit6 var portd.5 cnt var word digit var byte pattern var byte i var word first var byte second var byte third var byte fourth var byte fifth var byte sixth var byte seconds var byte mins var byte hour var byte ampm var portb.7 seconds=45 mins=59 hour=11 cnt=0 INTCON=%10100000 OPTION_REG=%00000000 TMR0=6 on interrupt goto isr INTCON=%10100000 trisa=0 trisd=0 trisb=0 trisc=1 ampm=1 loopa: button portc.3,1,255,1,i,0,loopa if portc.3=1 then seconds=seconds+1 endif if seconds>59 then seconds=0 mins=mins+1 endif if mins>59 then mins=0 hour=hour+1 endif if hour>11 then hour=1 ampm=0 endif goto loopa disable isr:TMR0=6 digit=hour dig 1 lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern porta=pattern digit6=1 pauseus 500 digit6=0 digit=hour dig 0 lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern porta=pattern digit5=1 pauseus 500 digit5=0 digit=mins dig 1 lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern porta=pattern digit4=1 pauseus 500 digit4=0 digit=mins dig 0 lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern porta=pattern digit3=1 pauseus 500 digit3=0 digit=seconds dig 1 lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern porta=pattern digit2=1 pauseus 500 digit2=0 digit=seconds dig 0 lookup digit,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F],pattern porta=pattern digit1=1 pauseus 500 digit1=0 intcon.2=0 resume enable end
A few things to note.
ON INTERRUPT will not give "true" interrupts. What happens is the code will wait till something like a PAUSE XX is finished before going to the ISR. Many time ON INTERRUPT is good enough, as long as the timing is not "super" critical. ASM interrupts will give true results but hard to setup at times. When you get a handle on this you will want to look at DT's Instant Interrupts. Pretty easy to setup and will give you "TRUE" interrupts.
No matter what method you use you will want the ISR to be as short as possible.
Now for something that might help you...
This is a very useful program
http://www.picbasic.co.uk/forum/cont....-PICMultiCalc
Now look at Timer 1, I think this will work the best in your case. It is a 16 bit timer.
Set the pre-scaler to 1:16 and pre-load to 3036 and you should have very close to a 1 Hz interrupt.
Dave
Always wear safety glasses while programming.
Bookmarks