Move backlight pwm to timerirq
This commit is contained in:
parent
5223cd4e24
commit
d1ddb909ff
4 changed files with 26 additions and 16 deletions
|
@ -35,7 +35,6 @@ extern volatile char last_sample;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned int tval;
|
unsigned int tval;
|
||||||
unsigned char bl_val, cmp_val; // backlight PWM
|
|
||||||
unsigned int slen;
|
unsigned int slen;
|
||||||
unsigned char *sdata;
|
unsigned char *sdata;
|
||||||
unsigned char sact;
|
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.
|
@ -42,7 +42,7 @@ void startTimerIRQ(void)
|
||||||
T0TCR = 0x02; // reset timer
|
T0TCR = 0x02; // reset timer
|
||||||
T0TC = 1870;
|
T0TC = 1870;
|
||||||
T0PR = 0x0e; // 15.000.000 Hz / 15 = 1.000.000 Hz --> PR = 15 - 1 = 0x0e
|
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
|
T0MCR = 0x03; // reset and issue IRQ on TC == MR0
|
||||||
T0TCR = 0x01; // enable timer
|
T0TCR = 0x01; // enable timer
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,37 @@
|
||||||
#include "timerfuncs.h"
|
#include "timerfuncs.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
|
||||||
|
#define TIMER_PRESCALER 20
|
||||||
|
|
||||||
struct CB callbacks[MAX_CB];
|
struct CB callbacks[MAX_CB];
|
||||||
unsigned long* timeouts[MAX_TO];
|
unsigned long* timeouts[MAX_TO];
|
||||||
|
unsigned char timerPrescaler = TIMER_PRESCALER;
|
||||||
|
unsigned char bl_val, cmp_val; // backlight PWM
|
||||||
|
|
||||||
|
// wird alle 0.25 ms aufgerufen (s. startTimerIRQ() in timerfuncs)
|
||||||
// wird alle 5 ms aufgerufen (s. startTimerIRQ() in timerfuncs)
|
|
||||||
// bearbeitet eingetragene "timer"
|
// bearbeitet eingetragene "timer"
|
||||||
void __attribute__ ((section(".text.fastcode"))) timerIRQ(void)
|
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;
|
unsigned int cnt;
|
||||||
struct CB *cur_cb;
|
struct CB *cur_cb;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue