stm32F4 7-segment display

574 views Asked by At

I have a problem with programming quad 7-segment display. I don't know how to make all multiplexed chars blinking. I'm programming in CooCox

multiplexing code (interrupt):

void TIM2_IRQHandler(){
    if (TIM_GetITStatus(TIM2,TIM_IT_Update)) {
        TIM_ClearITPendingBit(TIM2,TIM_IT_Update);
        GPIO_ResetBits(GPIOC,15); //turn off all display cells
        switch (disp) {
            case 1:
                decodeCharacters(digits[(alarm.RTC_AlarmTime.RTC_Minutes-time.RTC_Minutes)%10]); //called method decoding chars
                break;
            case 2:
                decodeCharacters(digits[(alarm.RTC_AlarmTime.RTC_Seconds-time.RTC_Seconds)/10]);
                break;
            case 3:
                decodeCharacters(digits[(alarm.RTC_AlarmTime.RTC_Seconds-time.RTC_Seconds)%10]);
                break;
            default:
                decodeCharacters(digits[(alarm.RTC_AlarmTime.RTC_Minutes-time.RTC_Minutes)/10]);
                break;
        }
        GPIO_ToggleBits(GPIOC,1<<disp); //turn on display cell
        disp = (disp+1)%4;
    }
}

where "disp" is unsigned integer.

1

There are 1 answers

2
Mikolaj On BEST ANSWER

I understand that you have a code that displays time and you want to make your digits blinking.

First thing that you need to do is to check how often your interrupt handler occurs. Then inside this handler you can create a static variable which will count time, e.g.

static unsigned int blinkCounter = 0;

if( blinkCounter < 500 )
{
    /* Turn off the display */
}
else
{
    /* Most of your current handler code */
}

if( blinkCounter > 1000 )
{
   blinkCounter = 0;
}

blinkCounter++;