1

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.

Bence Kaulics
  • 7,066
  • 7
  • 33
  • 63
Kris_1313
  • 79
  • 9

1 Answers1

0

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++;
Mikolaj
  • 43
  • 4
  • Ok, and what to do if I want only some digits blinking? – Kris_1313 Aug 29 '17 at 12:39
  • The most important is to understand the current code. In every interrupt call you update only one digit. If you want to digit only some of these digits you can divide your switch into two switches: the 1st switch inside the 'else' in code above (blinking part) and second outside the condition. – Mikolaj Aug 30 '17 at 08:37