Hi sayzer,
Thanks for the reply.
But i don't using eny pause in my code. I also using Intrrupt for high age detect from encoder and count.
Thanks
Hi sayzer,
Thanks for the reply.
But i don't using eny pause in my code. I also using Intrrupt for high age detect from encoder and count.
Thanks
Np.
Why don't you use 20Mhz Xtall ?
Your DEFINE is 12Mhz, are you using 12Mhz Xtall ?
Regards.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
My rules:In this case, i guess, you could remove the interrupt and do the job by reading the Timer register. Working 'round the multiple if/then statement you can improve it.
- Don't use Serout when the PIC have an internal USART, use HSEROUT instead.
- use Timer as counter when hardware allow
- keep ISR as short as possible to avoid latency etc etc
also...
When you start the PIC and IF PORTA.0=1 you make it jump to the ISR? Bad practiceCode:OPTION_REG = %00000000 On Interrupt Goto myint INTCON = $90 IF PORTA.0 = 1 THEN NINE LOOP: serOUT PORTC.6,T9600,[#b5,#b4,#b3,#b2,#b1,13]![]()
Last edited by mister_e; - 10th September 2006 at 18:07.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Thanks mister_e ,
this is my code, i use timer as counter.
but it count upto 256 and reset to 0, I see datasheet timer0 is 8 bit
how i set to tomer1 on pic16f877
'-------- PIC16F84A -----------------------
DEFINE OSC 16 ' use 16 MHZ oscillator
INCLUDE "MYLCD.BAS" ' LCD ON PORTB
input PORTA.4
OPTION_REG = %10110000 ' TMR0 clock source : RA4/T0CKI
' increment on low to high transition
' Prescaler assign to WDT
' WDT rate 1:1
INTCON = %10100000 ' Enable global interrupt
' Enable TMR0 overflow interrupt
ClockInput var PORTA.4 ' Input pin for signal
COUNTER var word ' Result of count to be send to 7 segment display
OverFlowVar var word
COUNTER = 0 ' set initial value of count
TMR0 = 0 ' reset prescaller
on interrupt goto MyInit
LOOP:
lcdout $fe,1
lcdout "count ", dec5 COUNTER
pause 20
COUNTER = OverFlowVar+ TMR0
OverFlowVar = 0 ' Reset OverFlowVar
goto Loop
disable
MyInit:
OverFlowVar = OverFlowVar + 65535
INTCON.2 = 0 ' clear overflow flag
TMR0 = 0 ' reload TMR0
resume
enable
As per the datasheet you'll have to use the PORTC.0 pin.
Code:T1CON=%00000110 ' Prescaller 1:1 ' osc=off ' no synchro ' ClockSource external PORTC.0
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks