my program can't compile through,anyone can help me

Status
Not open for further replies.

sheldonny

New Member
View attachment 63649View attachment 63649
#include <pic.h>
void initPORTB(void); //initialize portb
void initTMR1(void); //initialize TMR1
void interrupt TMR1INT(void); //TMR1 interrupt program
void display(void); //display program
int second=0; //counter variable
void main()
{
initPORTB(); //initialize portb
initTMR1(); //initialize TMR1
while(1){}
}
void initPORTB() //initialize PORTB
{
TRISB=0X00; //set PORTB is output
PORTB=0X00; //initialize PORTB output is 0;
}
void initTMR1()
{
T1CON&=0XC0; //set frequency ratio is 1:1,select internal clock ,close TMR1
GIE=0; //close interrupt
TMR1H=0X9E; //set TMR1 initial value=9e58H,the simulation frequency is 1MHz
TMR1L=0X58; //4*(ffff-9E58+1)=100ms
TMR1IF=0; //clear TMR1 interruption flag
TMR1IE=1; //enable TMR1 interrupt
PEIE=1; //enable Peripheral interrupt
GIE=1; //enable global interrupt
TMR1ON=1; //open TMR1
}
void interrupt TMR1INT() //TMR1 interruption program
{
GIE=0; //close interruption
TMR1IF=0; //clear interruption flag
second++; //counter add 1
display(); //display counter
TMR1H=0X9E; //reset counter initial value
TMR1L=0X58;
GIE=1; //open interruption
TMR10N=1; //open counter TMR1
}
void display()
{
int disp;
if(second>9)
{
disp++;
if(disp>9) disp=0; //out the rage of display,clear the value
second=0;
}
PORTB=(disp<<4)|second; //display
}


this is my program,I don't know where is wrong, can you help me find the mistake
 
Last edited:
what error or errors are you getting. Please cut and then paste the compiler output here.
 
Executing: "C:\HT-PIC\BIN\PICC.EXE" -C -E"test2.cce" "test2.c" -O"test2.obj" -Zg9 -O -ASMLIST -Q -MPLAB -16F877
Halting build on first failure as requested.
BUILD FAILED: Tue Apr 24 22:02:00 2012
 
If you could put it in CODE tags, it would preserve the spacing and make it easier to read, too.
 
Last edited:
the space exist at first,but when I copy on the forum,it disappear

True, but if you use code tags then it will keep it's format.

Either use the code button or type [code] before it and [/code] after it.

Mike.
 
Last edited by a moderator:
Spelling mistake " TMR10N=1; //open counter TMR1 "

a zero instead of an 'O'

TMR1ON = 1;
 
True, but if you use code tags then it will keep it's format.

Either use the code button or type [code] before it and [/code] after it.

Mike.

Exactly. I think it's "code" in capital letters, though. Just wanted to mention that. Maybe it works both ways?

Spelling mistake " TMR10N=1; //open counter TMR1 "

a zero instead of an 'O'

TMR1ON = 1;

Good eye!
 
Last edited by a moderator:
Exactly. I think it's "code" in capital letters, though. Just wanted to mention that. Maybe it works both ways?

I use lower case and it always works..

Good eye!

Not really! I copied the code and complied it...... That was the only error...
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…