Skip to main content
added 1533 characters in body
Source Link
Oli Glaser
  • 55.7k
  • 3
  • 78
  • 149

It appears your interrupt routine is being triggered too fast, and any faster leaves no time left to execute the main code so the uC will appear unresponsive.

For a typical display, a refresh rate around 50Hz is suitable to trick the eye into thinking it is continuous.
Adjust your timer for a period of around 10ms (100Hz divided by two displays equals 50Hz update for each display) between interrupts (if it's only an 8-bit timer use the prescaler to divide the clock down some more, or if the divider doesn't go high enough then as Mike says in the comments use a count variable in the ISR and execute the event every n interrupts. Or use the 16-bit timer)

EDIT - okay, so you fixed the interrupt timing to a more reasonable value but the flicker persists. The way you have the code in the ISR it seems that the period between turn off of one display and turn on of the other is fixed to the 1000us delay anyway, so as long as you are not calling the ISR so quickly as to make the uC unresponsive then it shouldn't matter too much (although obviously too quickly limits the time you have in your main loop to perform other stuff, so only go as fast as you need to stop flicker, say <400Hz or so)

Anyway, I would have thought the 1ms delay should be plenty to turn the PNP back off again. I'm assuming here that the pin is a push pull output with a reasonable drive for high and low (will check shortly)
So couple of things to try:

  • Try changing the 2k2 base resistors to say, 470Ω Assuming the pin is capable of it, this will provide a stronger drive to charge/discharge the capacitance (do you have a long trace/wiring?)
  • It's possible the PNP on the red display is "leaky". Check whether the red display ever turns off fully with all the digits on on the blue display. Changing the transistor wouldn't hurt anyway to make sure of this.

It would make some sense that the ghosting doesn;t happen on the blue display since that will have a higher forward voltage than the red display, so will turn off more quickly (and on more slowly)

If you have a scope probe the PNP base and collector lines whilst switching to see how long the transition is taking.

It appears your interrupt routine is being triggered too fast, and any faster leaves no time left to execute the main code so the uC will appear unresponsive.

For a typical display, a refresh rate around 50Hz is suitable to trick the eye into thinking it is continuous.
Adjust your timer for a period of around 10ms (100Hz divided by two displays equals 50Hz update for each display) between interrupts (if it's only an 8-bit timer use the prescaler to divide the clock down some more, or if the divider doesn't go high enough then as Mike says in the comments use a count variable in the ISR and execute the event every n interrupts. Or use the 16-bit timer)

It appears your interrupt routine is being triggered too fast, and any faster leaves no time left to execute the main code so the uC will appear unresponsive.

For a typical display, a refresh rate around 50Hz is suitable to trick the eye into thinking it is continuous.
Adjust your timer for a period of around 10ms (100Hz divided by two displays equals 50Hz update for each display) between interrupts (if it's only an 8-bit timer use the prescaler to divide the clock down some more, or if the divider doesn't go high enough then as Mike says in the comments use a count variable in the ISR and execute the event every n interrupts. Or use the 16-bit timer)

EDIT - okay, so you fixed the interrupt timing to a more reasonable value but the flicker persists. The way you have the code in the ISR it seems that the period between turn off of one display and turn on of the other is fixed to the 1000us delay anyway, so as long as you are not calling the ISR so quickly as to make the uC unresponsive then it shouldn't matter too much (although obviously too quickly limits the time you have in your main loop to perform other stuff, so only go as fast as you need to stop flicker, say <400Hz or so)

Anyway, I would have thought the 1ms delay should be plenty to turn the PNP back off again. I'm assuming here that the pin is a push pull output with a reasonable drive for high and low (will check shortly)
So couple of things to try:

  • Try changing the 2k2 base resistors to say, 470Ω Assuming the pin is capable of it, this will provide a stronger drive to charge/discharge the capacitance (do you have a long trace/wiring?)
  • It's possible the PNP on the red display is "leaky". Check whether the red display ever turns off fully with all the digits on on the blue display. Changing the transistor wouldn't hurt anyway to make sure of this.

It would make some sense that the ghosting doesn;t happen on the blue display since that will have a higher forward voltage than the red display, so will turn off more quickly (and on more slowly)

If you have a scope probe the PNP base and collector lines whilst switching to see how long the transition is taking.

added 68 characters in body
Source Link
Oli Glaser
  • 55.7k
  • 3
  • 78
  • 149

It appears your interrupt routine is being triggered too fast, and any faster leaves no time left to execute the main code so the uC will appear unresponsive.

For a typical display, a refresh rate around 50Hz is suitable to trick the eye into thinking it is continuous.
Adjust your timer for a period of around 10ms (100Hz divided by two displays equals 50Hz update for each display) between interrupts (if it's only an 8-bit timer use the prescaler to divide the clock down some more, or if the divider doesn't go high enough then as Mike says in the comments use a count variable in the ISR and execute the event every n interrupts. Or use the 16-bit timer)

It appears your interrupt routine is being triggered too fast, and any faster leaves no time left to execute the main code so the uC will appear unresponsive.

For a typical display, a refresh rate around 50Hz is suitable to trick the eye into thinking it is continuous.
Adjust your timer for a period of around 10ms (100Hz divided by two displays equals 50Hz update for each display) between interrupts (if it's only an 8-bit timer use the prescaler to divide the clock down some more)

It appears your interrupt routine is being triggered too fast, and any faster leaves no time left to execute the main code so the uC will appear unresponsive.

For a typical display, a refresh rate around 50Hz is suitable to trick the eye into thinking it is continuous.
Adjust your timer for a period of around 10ms (100Hz divided by two displays equals 50Hz update for each display) between interrupts (if it's only an 8-bit timer use the prescaler to divide the clock down some more, or if the divider doesn't go high enough then as Mike says in the comments use a count variable in the ISR and execute the event every n interrupts. Or use the 16-bit timer)

added 68 characters in body
Source Link
Oli Glaser
  • 55.7k
  • 3
  • 78
  • 149

It appears your interrupt routine is being triggered too fast, and any faster leaves no time left to execute the main code so the uC will appear unresponsive.

For a typical display, a refresh rate around 50Hz is suitable to trick the eye into thinking it is continuous.
Adjust your timer for a period of around 20ms10ms (100Hz divided by two displays equals 50Hz update for each display) between interrupts (if it's only an 8-bit timer use the prescaler to divide the clock down some more)

It appears your interrupt routine is being triggered too fast, and any faster leaves no time left to execute the main code so the uC will appear unresponsive.

For a typical display, a refresh rate around 50Hz is suitable to trick the eye into thinking it is continuous.
Adjust your timer for a period of around 20ms between interrupts (if it's only an 8-bit timer use the prescaler to divide the clock down some more)

It appears your interrupt routine is being triggered too fast, and any faster leaves no time left to execute the main code so the uC will appear unresponsive.

For a typical display, a refresh rate around 50Hz is suitable to trick the eye into thinking it is continuous.
Adjust your timer for a period of around 10ms (100Hz divided by two displays equals 50Hz update for each display) between interrupts (if it's only an 8-bit timer use the prescaler to divide the clock down some more)

Source Link
Oli Glaser
  • 55.7k
  • 3
  • 78
  • 149
Loading