Advertisement
zmatt

pwm register macros

Oct 25th, 2021 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. // all values are in timer clock cycles of the respective peripheral.
  2. // eCAP 0-2 run at 100 MHz, i.e. pwm values are in units of 10ns
  3. // PRUSS eCAP runs at 200 MHz, i.e. pwm values are in units of 5ns
  4. // ePWM 0-2 run at 100 MHz / prescale divider, configurable per peripheral.
  5. //
  6. // using these macros assumes the corresponding peripheral has already been
  7. // setup as pwm output in advance (from python)
  8.  
  9. // macros to get/set the pwm values (in range 0 .. period)
  10. #define EPWM0A  ( *(uint16_t volatile *)0x48300212 )
  11. #define EPWM0B  ( *(uint16_t volatile *)0x48300214 )
  12. #define EPWM1A  ( *(uint16_t volatile *)0x48302212 )
  13. #define EPWM1B  ( *(uint16_t volatile *)0x48302214 )
  14. #define EPWM2A  ( *(uint16_t volatile *)0x48304212 )
  15. #define EPWM2B  ( *(uint16_t volatile *)0x48304214 )
  16. #define ECAP0_PWM  ( *(uint32_t volatile *)0x48300114 )
  17. #define ECAP1_PWM  ( *(uint32_t volatile *)0x48302114 )
  18. #define ECAP2_PWM  ( *(uint32_t volatile *)0x48304114 )
  19.  
  20. // macros to get the pwm periods.
  21. // caution: if an eCAP has been configured to a period of 2**32 cycles then
  22. // this macro will yield 0 instead.
  23. #define EPWM0_PERIOD  ( *(uint16_t const *)0x4830020a + 1 )
  24. #define EPWM1_PERIOD  ( *(uint16_t const *)0x4830220a + 1 )
  25. #define EPWM2_PERIOD  ( *(uint16_t const *)0x4830420a + 1 )
  26. #define ECAP0_PWM_PERIOD  ( *(uint32_t const *)0x48300110 + 1 )
  27. #define ECAP1_PWM_PERIOD  ( *(uint32_t const *)0x48302110 + 1 )
  28. #define ECAP2_PWM_PERIOD  ( *(uint32_t const *)0x48304110 + 1 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement