- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I am using the LPC55s16 microcontroller in the scenario. I am working with both timers and PWM in CTIMER0 peripherals, but I didn't use the same time because the MCR register bits are the same. Is it possible to connect those two peripherals?
Here I attached the code.
PWM code
SYSCON->SYSTICKCLKSELX[0] |=0X02; // Oscillator 32 kHz clock.
SYSCON->CTIMERCLKSELX[0] |= 0x00; // 0 Main clock.
IOCON->PIO[1][2]= 0X003; // FUNC = 3 // CTIMER0_MAT1
SYSCON->AHBCLKCTRLX[1] = 1 << 26 ; // Enables the clock for the Timer 0.
SYSCON->PRESETCTRLSET[1] = 1 << 26 ; // Timer 0 reset control.
SYSCON->PRESETCTRLCLR[1] = 1 << 26 ; //clears the corresponding position in PRESETCTRL1.
CTIMER0->CTCR = 0X00;//Timer mode. Incremented every rising APB bus clock edge
CTIMER0->PR = 0X00;//The pre-scale counter is incremented on every APB bus clock
CTIMER0->PWMC = 1 << 3 ;// PWM mode is enabled for CTIMERn_MAT3.
CTIMER0->MCR = 1 << 4 ;// Reset on MR1: the TC will be reset if MR1 matches it.
CTIMER0->MR[3] =48000; //period
CTIMER0->MR[1] =24000; //duty cycle
CTIMER0->TCR |= 1 << 0; //Enabled. The timer counter and pre-scale counter are enabled
TIMER code
SYSCON->AHBCLKCTRLSET[1] = 1<<27; // Enables the clock for the Timer 1.
SYSCON->CTIMERCLKSEL.CTIMERCLKSEL1 = 0x00;
CTIMER1->CTCR = 0x00;
CTIMER1->TC = 0x00;
CTIMER1->PR = 0x00;
CTIMER1->PC = 0x00;
CTIMER1->MR[1] = MR_VALUE;//96000000;
CTIMER1->MCR |= 1U<<3; // Interrupt on Match1 compare
CTIMER1->MCR |= 1U<<4; // Reset timer on Match 1.
CTIMER1->TCR |= 1U<<1; // Manually Reset Timer1
CTIMER1->TCR &= ~(1U<<1); // Stop resetting the timer.
CTIMER1->IR |= 0xFF; // Clear MR1 interrupt flag
CTIMER1->TCR |= 1<<0; // Start timer
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content