Change LIRC to hardware PWM

This commit is contained in:
Telekatz 2017-07-04 19:01:44 +02:00
parent 0aeec3e680
commit ad448f1769
6 changed files with 66 additions and 6 deletions

View file

@ -58,9 +58,9 @@ proc betty_init { } {
# PLLCFG: 0x42 = psel = 10 (4) = msel= 00010 (3) = 240 mhz Fcco*/
mww 0xe01fc084 0x42
# Activate PLL settings
#mww 0xe01fc08c 0xaa
#mww 0xe01fc08c 0x55
#sleep 100
mww 0xe01fc08c 0xaa
mww 0xe01fc08c 0x55
sleep 100
# Memory Bank Configuration
# BCFG0: 16bit, rble, 2wst - 30 mhz : Betty: FLASH 0 @ 0x80000000
@ -96,8 +96,8 @@ proc betty_init { } {
proc flash_boop {IMAGE} {
reset init
flash erase_sector 0 0 last
flash write_bank 0 $IMAGE 0
reset run
flash write_bank 0 $IMAGE 0
reset run
}
proc start_debug {} {

Binary file not shown.

View file

@ -109,11 +109,46 @@ void defStopper(void)
void runIR(void)
{
T1TCR = 0x01;
/*
PWMTC = 0;
PWMPR = 7;
PWMMR0 = 0x1E6; // pwm rate
PWMMR2 = 0x00; // pwm value
PWMLER = 0x05;
PWMMCR = 0x03;
PWMPCR = (1<<10);
PWMTCR = 0x03;
PWMTCR = 0x09;
*/
PINSEL1 &= ~(3 << (10)); // IO
PINSEL1 |= (1 << (10)); // PWM5
PWMTC = 0; //Timer Counter
PWMPR = 0; //Prescale Register
PWMPC = 0; //Prescale Counter
PWMMR0 = 416; // pwm rate
PWMMR5 = 0; // pwm value
PWMLER = 0x21; //Latch Enable
PWMMCR = 0x02; //Match Control
PWMPCR |= (1<<13);
PWMTCR = 0x03;
PWMTCR = 0x09;
//FIOSET0 = (1<<21);
}
void stopIR(void)
{
T1TCR = 0x03;
PWMMR5 = 0; // pwm value
PWMLER = 0x21; //Latch Enable
}
void copyMapC(unsigned char *map)

View file

@ -36,6 +36,21 @@ extern ir_fn irEncoder;
void __attribute__ ((section(".text.fastcode"))) irIRQ(void)
{
c_cnt++;
irEncoder();
if(mod_enable) {
PWMMR5 = 200; // pwm value
PWMLER = 0x20; //Latch Enable
} else {
PWMMR5 = 0; // pwm value
PWMLER = 0x20; //Latch Enable
}
/*
if(c_cnt <= hi_border)
{
FIOSET0 = (mod_enable<<21);
@ -61,7 +76,7 @@ void __attribute__ ((section(".text.fastcode"))) irIRQ(void)
}
}
}
*/
T1IR = 1;
// VICVectAddr = 0;
}

View file

@ -32,6 +32,8 @@ extern volatile unsigned char mod_enable;
extern volatile unsigned int cycles;
extern volatile unsigned long keyMap[42];
volatile unsigned long act_freq;
/*
#define RAW_IDLE 0x00
#define RAW_HI 0x01
@ -290,6 +292,10 @@ void __attribute__ ((section(".text.fastcode"))) LIRC_Encode (void) {
ir.state = LIRC_HEAD_P;
}
}
T1MR0 = (15000000 / (act_freq)) * cycles;
}
void LIRC_Init(unsigned char map)
@ -340,6 +346,8 @@ void LIRC_Init(unsigned char map)
}
}
act_freq = freq;
T1MR0 = 15000000 / (freq * lo_border);

View file

@ -198,6 +198,8 @@ void cpu_idle ()
if(U0SCR)
return;
return;
/* only idle mode instead of power down when:
* * backlight on
* * IR transmission