sonar_abhi
New Member
Hello All,
I am using two 74HC595 Shift Resisters for a 4digit SSD.
The problem is that the display needs to be delayed while scanning through the digits. I do not want to use delay since while the display is on, nothing can work as the processor is busy in delay loop. So I thought I will use an interrupt based delay.
and the function that shifts the digits is as follows
I am using two 74HC595 Shift Resisters for a 4digit SSD.
The problem is that the display needs to be delayed while scanning through the digits. I do not want to use delay since while the display is on, nothing can work as the processor is busy in delay loop. So I thought I will use an interrupt based delay.
Code:
void InitTimer0(){
OPTION_REG = 0x87;
TMR0 = 6;
INTCON = 0xA0;
}
void Interrupt(){
if (TMR0IF_bit){
TMR0IF_bit = 0;
TMR0 = 6;
latdelay++;
if (latdelay>3){
portdelay=1;
latdelay=0;
}
}
}
and the function that shifts the digits is as follows
Code:
void shiftdata(char _shiftdata)
{
char i;
char temp;
int m,n;
temp = _shiftdata;
i=8;
while (i>0)
{
if (temp.F7==0)
{
SHIFT_DATA1 = 0;
}
else
{
SHIFT_DATA1 = 1;
}
temp = temp<<1;
SHIFT_CLOCK1 = 1;
if (latdelay>3 && portdelay==1){ //If I comment out this loop and add the Delay_ms(100) the system works fine displaying digits one by one
//Delay_ms(100); // else, all the digits are displayed simultaneously
SHIFT_CLOCK1 = 0;
i--;
portdelay = 0;
}
}
}