It is currently 23 Jan 2018 23:53

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: TMR0 if pic16f84a
PostPosted: 09 Aug 2011 01:31 
Offline

Joined: 26 Mar 2011 07:15
Posts: 44
hai all
i am trying to use tmro of pic16f84......
here is my code, i have used prescaler at 1:256 and wants to make a delay of 1s,, and after every 1s have incremented in a count variable and then displaying its value on 3 seven segment displays.... using multiplexing....
but that displays nothing...
please clear my mistakes and tell me also about them...




int digit1,digit2,digit3=0;
int count,counter,temp,kp=0;

void value(){
switch(kp){
case 0: kp=0x3f; break;
case 1: kp=0x06; break;
case 2: kp=0x5b; break;
case 3: kp=0x4f; break;
case 4: kp=0x66; break;
case 5: kp=0x6d; break;
case 6: kp=0x7d; break;
case 7: kp=0x07; break;
case 8: kp=0x7f; break;
case 9: kp=0x67; break;}
}

void getvalues(){
kp=count/100;
value();
digit1=kp;
kp=(count%100)/10;
value();
digit2=kp;
kp=count%10;
value();
digit3=kp; }


void main(){
TRISA=0;
TRISB=0;
PORTA=0;
PORTB=0;
OPTION_REG=0b01000111;
INTCON=0b10100000;
start:
//T0IF=0;
if(T0IF==1){
INTCON=0b10100000;
temp++;
if(temp==255){
temp=0;
counter++;
if(counter==122){
counter=0;
count++;
getvalues();
PORTA=0b01111;
PORTB=digit1;
delay_ms(2);
PORTA=0b10111;
PORTB=digit2;
delay_ms(2);
PORTA=0b11011;
PORTB=digit3;
delay_ms(2);
goto start;



}
}}
}


Top
 Profile  
 
 Post subject: Re: TMR0 if pic16f84a
PostPosted: 30 Apr 2012 02:33 
Offline

Joined: 24 Apr 2011 18:04
Posts: 5
hello ..

you are using interrupts right?
try writting the interrupt function
like this:
void interrupt() {
counter++;
TMR0 = 96;
INTCON = 0x20;
}
try and coment
:D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: