HELP with seven segment refresh

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HELP with seven segment refresh

512 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pindonga123 on Sun Nov 03 05:35:47 MST 2013
Hello. I have some problems and some doubt about seven segment refresh. I did two programs. One shows me the number 0 to 9 in the 6 digit that i have, it work very well. And other program that show me a numer for example 576837, it dont work very well because the digit are tenuous. When I execute the two programs only shows me the first. Theory says that in the second case, each digit have to turn on each 1/6=166 mseg, but it dont work. How is the correct sequence?. Clear the display---Turn the display---Pause?, Is it the general rule?
Here my code

int main(void)
{
set_pines();
Set_SysTick ();
while(1)
{
parpadeo ();
mostrar_dig (564738);
}
return 0 ;
}

void Set_SysTick (void)
{
SYSTICK_InternalInit (1);
SYSTICK_Cmd (ENABLE);
SYSTICK_IntCmd (ENABLE);
}

void SysTick_Handler (void)
{
SysTickCnt++;
}

void Delay (float tick)
{
unsigned long systickcnt;
systickcnt = SysTickCnt;
while ((SysTickCnt - systickcnt) < tick);
}

void parpadeo (void)
{
signed int i, j;
for (i=0; i<=9; i++)
{
for (j=0; j<=1; j++)
{
GPIO_ClearValue (0, clear);
Delay (200);
GPIO_SetValue (0, vector_b0);
GPIO_SetValue (0, vector_b1);
GPIO_SetValue (0, vector_b2);
GPIO_SetValue (0, vector_b3);
GPIO_SetValue (0, vector_b4);
GPIO_SetValue (0, vector_b5);
Delay (200);
}
}
}

void mostrar_dig (unsigned long num)
{
int i=0, vect[6]; /*vect [6] lo declaraba como unsigned long y no funcionaba el programa. Porque?*/
while (num > 0)
{
vect=num%10;
num=num/10;
i++;
}
i--;
while (i>=0)
{
switch (i)
{
case 0:
GPIO_ClearValue (0, clear);
GPIO_SetValue (0, vector_b0[vect]);
i--;
Delay (1);
break;
case 1:
GPIO_ClearValue (0, clear);
GPIO_SetValue (0, vector_b1[vect]);
i--;
Delay (1);
break;
case 2:
GPIO_ClearValue (0, clear);
GPIO_SetValue (0, vector_b2[vect]);
Delay (1);
i--;
break;
case 3:
GPIO_ClearValue (0, clear);
GPIO_SetValue (0, vector_b3[vect]);
i--;
Delay (1);
break;
case 4:
GPIO_ClearValue (0, clear);
GPIO_SetValue (0, vector_b4[vect]);
i--;
Delay (1);
break;
case 5:
GPIO_ClearValue (0, clear);
GPIO_SetValue (0, vector_b5[vect]);
Delay (1);
i--;
break;
default:
break;
}
}
}
Labels (1)
0 Kudos
0 Replies