No PWM support in LPCOpen for LPC17xx?

cancel
Showing results for 
Search instead for 
Did you mean: 

No PWM support in LPCOpen for LPC17xx?

Jump to solution
613 Views
danielholala
Contributor III

Hi all,

I'm developing on a LPC1769 using MCUXpresso IDE v10.1.1 [Build 606] [2018-01-02]  on Windows 10.

My own code should be based on LPCOpen's common chip-specific drivers. 

Therefore, I first imported the LPCOpen drivers "lpc_chip_175x_6x" into my MCUXpresso workspace. For this, I used the import wizard, selected the LPCOpen project archive "lpcopen_2_10_lpcxpresso_nxp_lpcxpresso_1769.zip" which came included with the IDE installation.

Skimming through the *.c and *.h LPCOpen driver files (in the imported "lpc_chip_175x_6x" project), the only reference to PWM (except for the motor controller pwm) which I could find was LPC_PWM1_BASE in chip_lpc177x_8x.h.

Adhering to the naming convention of the LPCOpen driver files, I expected to find a file, e.g., named pwm_177x_8x.[ch] or at least a register structure for the PWM registers. 

Any ideas why I'm missing these and where I could find them?

For now, I'm going to resort to the definitions provided in timer_17xx_40xx.[ch] as PWM is based on standard timer blocks and the register layout is very similar.

Thanks.

Daniel

Labels (1)
0 Kudos
1 Solution
153 Views
danielholala
Contributor III

Thanks Kerry,

I'm now using this PWM structure for accessing PWM registers. I derived the structure from the timer structure and cross-checked with the structure provided in the mcb1700 code bundle.

typedef struct { /*!< My PWM Structure */
 __IO uint32_t IR;   /*!< Interrupt Register.  */
 __IO uint32_t TCR;  /*!< Timer Control Register. */
 __IO uint32_t TC;   /*!< Timer Counter. */
 __IO uint32_t PR;   /*!< Prescale Register. The TC is incremented every PR+1 cycles of PCLK */
 __IO uint32_t PC;   /*!< Prescale Counter. The 32-bit PC is a counter which is incremented to the value stored in PR. */
 __IO uint32_t MCR;  /*!< Match Control Register. The MCR is used to control if an interrupt is generated and if the TC is reset when a Match occurs. */
 __IO uint32_t MR0;  /*!< Match Register 0. MR0 can be enabled in the MCR to reset the TC, stop both the TC and PC, and/or generate an interrupt when it matches the TC. */
 __IO uint32_t MR1;  /*!< Match Register 1.  */
 __IO uint32_t MR2;  /*!< Match Register 2.  */
 __IO uint32_t MR3;  /*!< Match Register 3.  */
      uint32_t RESERVED0;
 __IO uint32_t CCR;  /*!< Capture Control Register. */
 __I  uint32_t CR[4];/*!< Capture Registers. */
 __IO uint32_t MR4;  /*!< Match Register 4.  */
 __IO uint32_t MR5;  /*!< Match Register 5.  */
 __IO uint32_t MR6;  /*!< Match Register 6.  */
 __IO uint32_t PCR;  /*!< PWM Control Register. Enables PWM outputs and selects PWM channel types as either single edge or double edge controlled. */
 __IO uint32_t LER;  /*!< Load Enable Register. Enables use of new PWM match values. */
      uint32_t RESERVED1[7];
 __IO uint32_t CTCR; /*!< Count Control Register. The CTCR selects between Timer and Counter mode. */
} LPC_PWM_T;

#define LPC_PWM1 ((LPC_PWM_T *) LPC_PWM1_BASE)


‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

0 Kudos
7 Replies
154 Views
danielholala
Contributor III

Thanks Kerry,

I'm now using this PWM structure for accessing PWM registers. I derived the structure from the timer structure and cross-checked with the structure provided in the mcb1700 code bundle.

typedef struct { /*!< My PWM Structure */
 __IO uint32_t IR;   /*!< Interrupt Register.  */
 __IO uint32_t TCR;  /*!< Timer Control Register. */
 __IO uint32_t TC;   /*!< Timer Counter. */
 __IO uint32_t PR;   /*!< Prescale Register. The TC is incremented every PR+1 cycles of PCLK */
 __IO uint32_t PC;   /*!< Prescale Counter. The 32-bit PC is a counter which is incremented to the value stored in PR. */
 __IO uint32_t MCR;  /*!< Match Control Register. The MCR is used to control if an interrupt is generated and if the TC is reset when a Match occurs. */
 __IO uint32_t MR0;  /*!< Match Register 0. MR0 can be enabled in the MCR to reset the TC, stop both the TC and PC, and/or generate an interrupt when it matches the TC. */
 __IO uint32_t MR1;  /*!< Match Register 1.  */
 __IO uint32_t MR2;  /*!< Match Register 2.  */
 __IO uint32_t MR3;  /*!< Match Register 3.  */
      uint32_t RESERVED0;
 __IO uint32_t CCR;  /*!< Capture Control Register. */
 __I  uint32_t CR[4];/*!< Capture Registers. */
 __IO uint32_t MR4;  /*!< Match Register 4.  */
 __IO uint32_t MR5;  /*!< Match Register 5.  */
 __IO uint32_t MR6;  /*!< Match Register 6.  */
 __IO uint32_t PCR;  /*!< PWM Control Register. Enables PWM outputs and selects PWM channel types as either single edge or double edge controlled. */
 __IO uint32_t LER;  /*!< Load Enable Register. Enables use of new PWM match values. */
      uint32_t RESERVED1[7];
 __IO uint32_t CTCR; /*!< Count Control Register. The CTCR selects between Timer and Counter mode. */
} LPC_PWM_T;

#define LPC_PWM1 ((LPC_PWM_T *) LPC_PWM1_BASE)


‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

0 Kudos
153 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Danielholala,

OK, it's good!

Do you have any problem about it? If you have the problem about this topic, just let me know!

If your question is solved, please help me to mark the correct answer, just to close this case, thank you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
153 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi danielholala,

   If you need the PWM driver for LPC17xx, you can download the MCB1700 sample code, there has the according PWM project:

MCB1700 Sample Code Bundle for LPC1769 Peripherals using LPCXpresso | www.LPCware.com 

  Please check the PWM project in the above link.

Wish it helps you!

Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

153 Views
danielholala
Contributor III

Hi Kerry,

Thanks for getting back to me and providing help.

I downloaded "mcb1700.code_.bundle.lpc1769.lpcxpresso" bundle and I skimmed through the sample code. I found the PWM example in the aptly named folder "PWM". :-)

As expected, the code illustrates setting up and changing PWM registers as well as using an PWM interrupt handler. 

That code includes "lpc17xx.h" . Indeed, there's a "LPC17xx.h" file in the CMSISv2_LPC17xx folder and it contains the wanted register structure LPC_PWM_TypeDef.

However, this raises questions:

a) Why does the code include "lpc17xx.h" when the only available header file is named in upper case. Windows seems to be lenient with respect to case in file names, but at least on Linux, gcc is case sensitive and as such I expect that this code would not compile out of the box.

b) Why is the PWM register structure missing from the official LPCOpen bundle for LPC1769 when obviously the definition exists?

c) I downloaded the bundle from http://host.lpcware.com but apparently that site will be shut down soon. Where will this source code be found when lpcware.com ceases to exist? Maybe this is a good time for NXP engineers to update the LPCOpen bundle for LPC17xx family.

Thanks.

Have a good weekend,

Bye

Daniel

0 Kudos
153 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Danielholala,

   Answer your several questions:

a) Why does the code include "lpc17xx.h" when the only available header file is named in upper case. Windows seems to be lenient with respect to case in file names, but at least on Linux, gcc is case sensitive and as such I expect that this code would not compile out of the box.

 Answer: I think it is the code structure question, this header file in the CMSIS driver have no compile problem, so to customer, they can use it directly.

b) Why is the PWM register structure missing from the official LPCOpen bundle for LPC1769 when obviously the definition exists?

Answer: LPCopen doesn't contain all the code, that's why I recommend you the code bundle project.

c) I downloaded the bundle from http://host.lpcware.com but apparently that site will be shut down soon. Where will this source code be found when lpcware.com ceases to exist? Maybe this is a good time for NXP engineers to update the LPCOpen bundle for LPC17xx family.

Answer:Yes, lpcware actually already be shut down, but this code bundle still leave there. please don't worry, even the lpcware don't have it, if we have it, we also will share the code with you in the community. If this code bundle works on your side, I suggest you refer to it directly. The lpcopen code for lpc1769 seems won't be updated.

Wish it helps you!

Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
153 Views
marysoniadurom
Contributor II

Hi Kerry,

Could you please share PWM code for LPC1768 for me. I am unable to download it from the above link.

0 Kudos
153 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Wish it helps you!

0 Kudos