AnsweredAssumed Answered

FreeRTOS PWM Macro: correct usage

Question asked by Erik Friedel on Jul 23, 2018
Latest reply on Jul 4, 2019 by Mario Ghecea



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");
      PRINTF("config Sample \n\r");
      PRINTF("config Period \n\r");
      PRINTF("done \n\n\r"); 
      return 0;

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: Page4207