AnsweredAssumed Answered

FreeRTOS PWM Macro: correct usage

Question asked by Erik Friedel on Jul 23, 2018
Latest reply on Aug 14, 2018 by Tomasz Sliwinski

Hello

 

I am currently working on an i.MX7s on the M4 side and try power my LED (for testing purpose) via PWM.

If I hardcode the Register everything works fine. But this is kinda dirty I know.

 

#define PWM1_Control  0x30660000
#define PWM1_Sample   0x3066000c
#define PWM1_Period   0x30660010

#define READ_PWM1_Control()  (*(volatile uint32_t *)PWM1_Control)

#define WRITE_PWM1_Sample(val)  ((*(volatile uint32_t *)PWM1_Sample) = (val))

#define WRITE_PWM1_Period(val)  ((*(volatile uint32_t *)PWM1_Period) = (val))


#include <stdint.h>
#include <stdbool.h>
#include "debug_console_imx.h"
#include "board.h"

int enable_PWM()
{
      PRINTF("\nenable PWM\n\n\r");
      WRITE_PWM1_Control(0x01c30000); 
      WRITE_PWM1_Sample(0x8000);
      PRINTF("config Sample \n\r");
      WRITE_PWM1_Period(0xf000);
      PRINTF("config Period \n\r");
      WRITE_PWM1_Control(0x01c30001);
      PRINTF("done \n\n\r"); 
      return 0;
}

 

https://github.com/TimesysGit/freertos-imx7/tree/BSP_1.0.1_TS/platform/devices/MCIMX7D/include

Here (search for "PWM Peripheral Access Layer") are the Makros for the PWM. Can someone give me two or three lines of code so I can try to figure it out how it works? Ref. Manual here: https://www.nxp.com/docs/en/reference-manual/IMX7DRM.pdf Page4207

 

Thanks

Outcomes