Hi
i am new to c,and i know little assembly language
i want to flash the LED one by one from right to left and left to write using 'c ' with some delay.
i am using 'Explorer 16 development board'
in assembly we use rrc,rlc instructions ,the codes are very less.
but i am writing in c ,the program is big ,but this program is working.
my question is how to write this program in simple way?
pls help me
i am new to c,and i know little assembly language
i want to flash the LED one by one from right to left and left to write using 'c ' with some delay.
i am using 'Explorer 16 development board'
in assembly we use rrc,rlc instructions ,the codes are very less.
but i am writing in c ,the program is big ,but this program is working.
my question is how to write this program in simple way?
pls help me
Code:
/* LED's ON one by one from left to right and right to left with 0.25 sec delay in PORTA*/
#include <p24FJ128GA010.h>
#define DELAY 15625 //31250,0.5 sec //62500,1 sec delay//
main ()
{
//Code goes here
AD1PCFG = 0xFFFF; // all pins are digital
TRISA = 0xFF00; // bit 0-7 output,bit 8-15 input
T1CON = 0x8030; // timer1 on,input clock prescale 256,internal clock(FOSC/2)
LATAbits.LATA0 = 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA0 = 0;
LATAbits.LATA1 = 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA1 = 0;
LATAbits.LATA2 = 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA2 = 0;
LATAbits.LATA3 = 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA3 = 0;
LATAbits.LATA4= 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA4 = 0;
LATAbits.LATA5= 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA5 = 0;
LATAbits.LATA6= 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA6 = 0;
LATAbits.LATA7= 1;
// TMR1 = 0;
// while(TMR1< DELAY)
// {
// }
// LATAbits.LATA7 = 0;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA7 = 0;
LATAbits.LATA6 = 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA6 = 0;
LATAbits.LATA5 = 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA5 = 0;
LATAbits.LATA4 = 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA4 = 0;
LATAbits.LATA3= 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA3 = 0;
LATAbits.LATA2= 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA2 = 0;
LATAbits.LATA1= 1;
TMR1 = 0;
while(TMR1< DELAY)
{
}
LATAbits.LATA1 = 0;
LATAbits.LATA0= 1;
}