Chullaa
Advanced Member level 4
Hi
I am using PIC16F877A, CCS C v4.057, and proteus v7.7. I made a LED fleshing cube and it is working fine. But my program is restarting after few seconds. I have disabled WDT. CLOCK= 4MHZ
SCHEMATIC
I am using PIC16F877A, CCS C v4.057, and proteus v7.7. I made a LED fleshing cube and it is working fine. But my program is restarting after few seconds. I have disabled WDT. CLOCK= 4MHZ
SCHEMATIC
Code:
#include "J:\Data\UIT WORK\FYP\Workshop\Material\lecture 04\LED PROJECT\CODE\led project.h"
void TRBL(int k);
void TRBL_Rv(int k);
void TRBL_all(int k,int j);
void msd(int td);
#define fo portb0
#define ba portb1
#define to portb2
#define le portb3
#define ri portb4
#define bo portb5
unsigned int k,i,j;
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
// TODO: USER CODE!!
TRISB=0x00;
PORTB=0x00;
while(1)
{
TRBL(500);
TRBL_RV(500);
TRBL_all(3,500);
}
}
void TRBL(k)
{
to=1; // top on
delay_ms(k);
to=0;
ri=1; //right on
delay_ms(k);
ri=0;
bo=1; //bottom on
delay_ms(k);
bo=0;
le=1; //left on
delay_ms(k);
le=0;
}
void TRBL_Rv(k)
{
to=1; // top on
delay_ms(k);
to=0;
le=1; //left on
delay_ms(k);
le=0;
bo=1; //bottom on
delay_ms(k);
bo=0;
ri=1; //left on
delay_ms(k);
ri=0;
}
void TRBL_all(k,j)
{
while(k>0)
{
to=le=ri=bo=1;
delay_ms(j);
to=le=ri=bo=0;
j=j*2;
delay_ms(j); ///////////////Here is my PROGRAM RESTARTS
k--;
}
}
void msd(int td)
{
for(i=0;i<td;i++)
for(j=0;j<135;j++)
{}
}