How to set interrupt and pwm sctimer lpc546xx (Config Tools)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to set interrupt and pwm sctimer lpc546xx (Config Tools)

1,234 次查看
robsongordo2017
Contributor I
Configure SCTimer with PWM Mode and interrupt with pinout togle event using Config Tools 
on LPC546xx. The PWM signal is generated perfectly but the interruption does not occur 
or the vector does not point to the routine. Note below the code generated after 
compiling config tools. 
/***********************************************************************************************************************
 * SCTimer_0 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'SCTimer_0'
- type: 'sctimer'
- mode: 'basic'
- type_id: 'sctimer_11116c58643bd290f0e74db0acbc9466'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'SCT0'
- config_sets:
  - main:
    - config:
      - clockMode: 'kSCTIMER_System_ClockMode'
      - clockSource: 'SynchronousFunctionClock'
      - clockSourceFreq: 'GetFreq'
      - SCTInputClockSourceFreq: 'custom:0'
      - clockSelect: 'kSCTIMER_Clock_On_Rise_Input_0'
      - enableCounterUnify: 'true'
      - enableBidirection_l: 'true'
      - enableBidirection_h: 'false'
      - prescale_l: '1'
      - prescale_h: '1'
      - outInitState: 'SCTIMER_OUTPUT_7_MASK'
    - enableIRQ: 'true'
    - interrupt:
      - IRQn: 'SCT0_IRQn'
      - enable_priority: 'false'
      - enable_custom_name: 'false'
    - enableLTimer: 'true'
    - enableHTimer: 'false'
    - pwms:
      - 0:
        - output: 'kSCTIMER_Out_7'
        - level: 'kSCTIMER_HighTrue'
        - dutyCyclePercent: '75'
    - pwmMode: 'kSCTIMER_CenterAlignedPwm'
    - pwmFrequency: '20000'
    - events:
      - 0:
        - type: 'kSCTIMER_OutputRiseEvent'
        - output: 'kSCTIMER_Out_7'
        - actions: []
    - states:
      - 0:
        - pwms: 'pwm0'
        - events: 'event0'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
const sctimer_config_t SCTimer_0_initConfig = {
  .enableCounterUnify = true,
  .clockMode = kSCTIMER_System_ClockMode,
  .clockSelect = kSCTIMER_Clock_On_Rise_Input_0,
  .enableBidirection_l = true,
  .enableBidirection_h = false,
  .prescale_l = 0,
  .prescale_h = 0,
  .outInitState = SCTIMER_OUTPUT_7_MASK
};
const sctimer_pwm_signal_param_t SCTimer_0_pwmSignalsConfig[1] = {
  {
    .output = kSCTIMER_Out_7,
    .level = kSCTIMER_HighTrue,
    .dutyCyclePercent = 75
  }
};
uint32_t SCTimer_0_pwmEvent[1];
uint32_t SCTimer_0_event[1];

void SCTimer_0_init(void) {
  SCTIMER_Init(SCTIMER_0_PERIPHERAL, &SCTimer_0_initConfig);
  /* Initialization of state 0 */
  SCTIMER_SetupPwm(SCTIMER_0_PERIPHERAL, &SCTimer_0_pwmSignalsConfig[0], kSCTIMER_CenterAlignedPwm, 20000U, SCTIMER_0_CLOCK_FREQ, &SCTimer_0_pwmEvent[0]);
  SCTIMER_CreateAndScheduleEvent(SCTIMER_0_PERIPHERAL, kSCTIMER_OutputRiseEvent, 0, kSCTIMER_Out_7, kSCTIMER_Counter_L, &SCTimer_0_event[0]);
  /* Enable interrupt SCT0_IRQn request in the NVIC */
  EnableIRQ(SCTIMER_0_IRQN);
  SCTIMER_StartTimer(SCTIMER_0_PERIPHERAL, kSCTIMER_Counter_L);
}

... and ....

void EV_InterruptSCT0(void)
{  temp_timer++;    if(temp_timer & 0x0001) PIO_test_ON();  else PIO_test_OFF(); }
 
// Oscilloscope has no signal at PIO_test, but the pwm 20KHz at PIO_7, 
// duty 75% OK. The interruption does not happen

... and ....(main)

BOARD_InitPeripherals();
SCTIMER_SetCallback(SCT0,EV_InterruptSCT0,0);
0 项奖励
回复
1 回复

1,158 次查看
soledad
NXP Employee
NXP Employee

Hi, 

Could you please double check in the LPC54608.h the IRQ name, in code you have

"EnableIRQ(SCTIMER_0_IRQN);"

I found the following definition 

pastedImage_1.png

In addition please check the ISR vector. 

pastedImage_2.png

I hope this helps, 

Have a nice day!

Regards 

Soledad

0 项奖励
回复