While playing a bit with the VGA generator code posted somewhere in this site, found this pwm problem.
Please, can someone tell me why I don´t get pwm interrupts 4 and 6 using this code?
I´m using mbed, lpcxpresso compiler (a tuned gcc) and fastlib.
...
fl_power_pwm1(FL_ON);
fl_select_clock_pwm1(FL_CLOCK_DIV1);
fl_pinsel(2, 1, FL_FUNC_ALT1, FL_FLOATING, FL_FLOATING); // PWM1.2, no pullup/down
fl_pwm_set_prescale(4); // 100/25 = 4
fl_pwm_config_match(0, FL_ON, FL_ON, FL_OFF); // interrupt, reset, !stop
fl_pwm_set_match(0, 800); // 800 dot clocks
fl_pwm_set_match(2, 704); // go low at 704/high again at 800
fl_pwm_config_match(2, FL_OFF, FL_OFF, FL_OFF); // interrupt, reset, !stop
fl_pwm_set_match(4, 48); // start visible line
fl_pwm_config_match(4, FL_ON, FL_OFF, FL_OFF); // interrupt, reset, !stop
fl_pwm_set_match(6, 688); // end visible line 688-48=640
fl_pwm_config_match(6, FL_ON, FL_OFF, FL_OFF); // interrupt, reset, !stop
fl_pwm_config_edges(2, FL_SINGLE_EDGE);
fl_pwm_config_edges(4, FL_SINGLE_EDGE);
fl_pwm_config_edges(6, FL_SINGLE_EDGE);
fl_pwm_output_enable(2, FL_ENABLE); //
fl_pwm_latch_match_all();
fl_nvic_interrupt_set_enable(FL_NVIC_INT_PWM); // enable PWM interrupts
fl_pwm_timer_counter_enable(FL_ENABLE);
fl_pwm_enable(FL_ENABLE);
...
//Interrupt handler
void PWM1_IRQHandler(void) {
uint32_t regval=*FL_PWM1IR;
if (regval & (1 << 0)) { //
printf("got this one");
*FL_PWM1IR=(regval & (1 << 0));
}
else if (regval & (1 << 8)) { //start visible line
printf("but no this");
*FL_PWM1IR=(regval & (1 << 8));
}
else if (regval & (1 << 10)) { //end visible line
printf("but no this");
*FL_PWM1IR=(regval & (1 << 10));
}
}
Hi all!
While playing a bit with the VGA generator code posted somewhere in this site, found this pwm problem. Please, can someone tell me why I don´t get pwm interrupts 4 and 6 using this code? I´m using mbed, lpcxpresso compiler (a tuned gcc) and fastlib.
Thanks in advance!
pwm setting code:
... fl_power_pwm1(FL_ON); fl_select_clock_pwm1(FL_CLOCK_DIV1); fl_pinsel(2, 1, FL_FUNC_ALT1, FL_FLOATING, FL_FLOATING); // PWM1.2, no pullup/down fl_pwm_set_prescale(4); // 100/25 = 4 fl_pwm_config_match(0, FL_ON, FL_ON, FL_OFF); // interrupt, reset, !stop fl_pwm_set_match(0, 800); // 800 dot clocks fl_pwm_set_match(2, 704); // go low at 704/high again at 800 fl_pwm_config_match(2, FL_OFF, FL_OFF, FL_OFF); // interrupt, reset, !stop fl_pwm_set_match(4, 48); // start visible line fl_pwm_config_match(4, FL_ON, FL_OFF, FL_OFF); // interrupt, reset, !stop fl_pwm_set_match(6, 688); // end visible line 688-48=640 fl_pwm_config_match(6, FL_ON, FL_OFF, FL_OFF); // interrupt, reset, !stop fl_pwm_config_edges(2, FL_SINGLE_EDGE); fl_pwm_config_edges(4, FL_SINGLE_EDGE); fl_pwm_config_edges(6, FL_SINGLE_EDGE); fl_pwm_output_enable(2, FL_ENABLE); // fl_pwm_latch_match_all(); fl_nvic_interrupt_set_enable(FL_NVIC_INT_PWM); // enable PWM interrupts fl_pwm_timer_counter_enable(FL_ENABLE); fl_pwm_enable(FL_ENABLE); ... //Interrupt handler void PWM1_IRQHandler(void) { uint32_t regval=*FL_PWM1IR; if (regval & (1 << 0)) { // printf("got this one"); *FL_PWM1IR=(regval & (1 << 0)); } else if (regval & (1 << 8)) { //start visible line printf("but no this"); *FL_PWM1IR=(regval & (1 << 8)); } else if (regval & (1 << 10)) { //end visible line printf("but no this"); *FL_PWM1IR=(regval & (1 << 10)); } }