Here is my code: Doesn't work at isis simulation
Please tell me, whats wrong. Using PIC16f877a @ 11.0592MHz
Rich (BB code):
#define step1 0x20
#define step2 0x10
#define step3 0x08
#define step4 0x04
int working, step_no;
void step_lookup()
{
if(step_no==1)
working=step1;
if(step_no==2)
working=step1|step2;
if(step_no==3)
working=step2;
if(step_no==4)
working=step2|step3;
if(step_no==5)
working=step3;
if(step_no==6)
working=step3|step4;
if(step_no==7)
working=step4;
if(step_no==8)
working=step4|step1;
}
void step_update()
{
step_no++;
if(step_no>8)
step_no=1;
step_lookup();
PORTB = working;
}
void tmr0_init()
{
ei();
T0CS = 0;
TMR0IE=1;
TMR0IF=0;
TMR0=50;
PEIE=1;
}
void main()
{
tmr0_init();
TRISB=0x00;
PORTB=0x00;
while(1)
{
}
}
void interrupt isr(void)
{
if(TMR0IF==1)
step_update();
TMR0IF=0;
TMR0=50;
}
Please tell me, whats wrong. Using PIC16f877a @ 11.0592MHz
Last edited: