Move backlight pwm to timerirq

This commit is contained in:
Telekatz 2017-07-15 18:47:26 +02:00
parent 5223cd4e24
commit d1ddb909ff
4 changed files with 26 additions and 16 deletions

View file

@ -35,7 +35,6 @@ extern volatile char last_sample;
*/
unsigned int tval;
unsigned char bl_val, cmp_val; // backlight PWM
unsigned int slen;
unsigned char *sdata;
unsigned char sact;
@ -211,16 +210,4 @@ void __attribute__ ((section(".text.fastcode"))) soundIRQ (void)
}
}
/* // backlight pwm
cmp_val += bl_val;
if (cmp_val >= 63)
{
FIODIR0 |= (1<<4); // sck0/P0.4
cmp_val -= 63;
}
else
{
FIODIR0 &= ~(1<<4); // sck0/P0.4
}
*/
}

Binary file not shown.

View file

@ -42,7 +42,7 @@ void startTimerIRQ(void)
T0TCR = 0x02; // reset timer
T0TC = 1870;
T0PR = 0x0e; // 15.000.000 Hz / 15 = 1.000.000 Hz --> PR = 15 - 1 = 0x0e
T0MR0 = 5000; // 1.000.000 Hz / 5000 = 200 Hz = 5 msec intervall time
T0MR0 = 250; // 1.000.000 Hz / 250 = 4000 Hz = 0,25msec intervall time
T0MCR = 0x03; // reset and issue IRQ on TC == MR0
T0TCR = 0x01; // enable timer

View file

@ -21,14 +21,37 @@
#include "timerfuncs.h"
#include "lcd.h"
#define TIMER_PRESCALER 20
struct CB callbacks[MAX_CB];
unsigned long* timeouts[MAX_TO];
unsigned char timerPrescaler = TIMER_PRESCALER;
unsigned char bl_val, cmp_val; // backlight PWM
// wird alle 5 ms aufgerufen (s. startTimerIRQ() in timerfuncs)
// wird alle 0.25 ms aufgerufen (s. startTimerIRQ() in timerfuncs)
// bearbeitet eingetragene "timer"
void __attribute__ ((section(".text.fastcode"))) timerIRQ(void)
{
// backlight pwm
cmp_val += bl_val;
if (cmp_val >= 63)
{
FIODIR0 |= (1<<4); // sck0/P0.4
cmp_val -= 63;
}
else
{
FIODIR0 &= ~(1<<4); // sck0/P0.4
}
if(--timerPrescaler) {
T0IR = 1;
return;
}
timerPrescaler = TIMER_PRESCALER;
//5 msec intervall time
unsigned int cnt;
struct CB *cur_cb;