Skip to content

Commit

Permalink
imx8mm-var-dart: assign PWM3 to M4 using RDC
Browse files Browse the repository at this point in the history
  This fix the PWM3 behaviour after linux boot
  The PWM is corrupted while linux is booting

Signed-off-by: FrancescoFerraro <[email protected]>
  • Loading branch information
FrancescoFerraro authored and morishitaandre committed Sep 16, 2024
1 parent 4667217 commit 4a0257d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions boards/dart_mx8mm/driver_examples/pwm/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "fsl_pwm.h"

#include "fsl_common.h"
#include "fsl_rdc.h"

/*******************************************************************************
* Definitions
******************************************************************************/
Expand All @@ -21,6 +23,7 @@
#define DEMO_PWM_IRQHandler PWM3_IRQHandler
/*! @brief PWM period value. PWMO (Hz) = PCLK(Hz) / (period +2) */
#define PWM_PERIOD_VALUE 30
#define APP_RDC_PERIPH_PWM3 kRDC_Periph_PWM3

/*******************************************************************************
* Prototypes
Expand All @@ -31,6 +34,8 @@
******************************************************************************/
volatile uint32_t pwmDutycycle = 0U;
volatile bool pwmDutyUp = true; /* Indicate PWM Duty cycle is increase or decrease */
rdc_domain_assignment_t assignment;
rdc_periph_access_config_t periphConfig;

/*******************************************************************************
* Code
Expand Down Expand Up @@ -66,6 +71,21 @@ void DEMO_PWM_IRQHandler(void)
SDK_ISR_EXIT_BARRIER;
}

static void APP_RDC_Periph(void)
{
PRINTF("RDC Peripheral access control\r\n");

/*
* Make PWM3 accessible only by M4
*/
RDC_GetDefaultPeriphAccessConfig(&periphConfig);
periphConfig.periph = APP_RDC_PERIPH_PWM3;
periphConfig.policy = RDC_ACCESS_POLICY(1, kRDC_ReadWrite);
/* Set peripheral to accessible by M4 domain only. */
RDC_SetPeriphAccessConfig(RDC, &periphConfig);
}


/*!
* @brief Main function
*/
Expand All @@ -81,6 +101,7 @@ int main(void)
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
BOARD_InitMemory();
APP_RDC_Periph();

PRINTF("\r\nPWM driver example.\r\n");

Expand Down

0 comments on commit 4a0257d

Please sign in to comment.