I have a T4.1 running a 4 channel trailing edge dimmer board.
There are 2 interrupts running; 1 is a hardware interrupt which fires every 10mS to indicate ac mains zero crossing point (UK 50Hz),
Code:
void zeroCrossingInt() //This is a hardware interrupt which occurs at 100Hz rate
{
for (int i=0; i<4; i++)
if (DimActual[i] > 0)
digitalWrite(Dim[i], 1);
dimTickCtr = 0;
DimTimer1.begin(hwTimer1, DimScaler);
}
the other is a timer which fires every 100uS which gives 1% resolution for turning each channel off.
Code:
void hwTimer1() //This is a Timer Interrupt which occurs 100x for each mains half cycle = 10kHz
{
dimTickCtr++;
for (int i=0; i<4; i++)
if (dimTickCtr >= DimActual[i])
digitalWrite(Dim[i], 0);
DimTimer1.begin(hwTimer1, DimScaler);
}
Everything else runs in a pseudo real time operating loop which cycles every 50mS. I've had a test board running for months with an RPI changing the dimmer values every minute.
This all works great, except for the occasional flicker on the lamps, presumably when the T4.1 gets busy and I discovered that by overclocking it, the flicker disappears completely. However, when overclocked, the T4.1 crashes and reboots intermittently.
I'd always suspect my code first, but since it runs perfectly at 600MHz, I think I'm in the clear.
Anyone have any ideas what might be causing the problem?