Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PWM on nuvoton NUC100LD2DN

Status
Not open for further replies.

Fai

New Member
hi, I,m fai

Does anyone ever use PWM on Nuvoton NUC100 series..? I,m familiar with AVR and I want migration to ARM series, and I try ARM Cortex M0 from nuvoton. I'm confuse, how to setting for duty cycle,. I,m using Coocox and I make initialization system using Co Smart, i try change CMR and CNR value but not change on output. I get refference from NUC100 Series Driver Reference Guide but I'm still do not understand. Below my code.



#include "NUC1xx.h"
#include "DrvSYS.h"
#include "DrvGPIO.h"
#include "DrvPWM.h"

/*************************************************************
* SYS Initialization Code Template
**************************************************************/
void SYSCtl_Init()
{

/* Unlock protected registers */
DrvSYS_UnlockProtectedReg();

/* Select the osc clock source */
DrvSYS_SetOscCtrl(E_SYS_XTL12M, 1);

/* Select the HCLK source */
DrvSYS_SelectHCLKSource(0);

/* Set the HCLK clock divider */
DrvSYS_SetClockDivider(E_SYS_HCLK_DIV, 0);

/* Select the clock source */
DrvSYS_SelectSysTickSource(0);

DrvSYS_LockProtectedReg();
}

void PWM_Init()
{
S_DRVPWM_TIME_DATA_T sPt_2;
uint8_t u8Timer_2;
/* Enable PWM clock */
DrvPWM_Open();

/* Set PWM2 Pin */
outpw(&SYS->GPAMFP, inpw(&SYS->GPAMFP) | (0x1<<14));
outpw(&SYS->ALTMFP, inpw(&SYS->ALTMFP) & ~(0x1<<11));

/* Enable PWM clock */
DrvPWM_SelectClockSource(DRVPWM_TIMER2, DRVPWM_EXT_12M);

/* PWM2 Timer property */
sPt_2.u8Mode = DRVPWM_AUTO_RELOAD_MODE;
sPt_2.u32Frequency = 0;
sPt_2.u8PreScale = 0;
sPt_2.u8ClockSelector = DRVPWM_CLOCK_DIV_1;
sPt_2.u8HighPulseRatio = 0;
sPt_2.i32Inverter = FALSE;
sPt_2.u32Duty = 0;
u8Timer_2 = DRVPWM_TIMER2;

/* Set PWM Timer2 Configuration */
DrvPWM_SetTimerClk(DRVPWM_TIMER2, &sPt_2);

/* Enable in/out for PWM Timer2 */
DrvPWM_SetTimerIO(DRVPWM_TIMER2, 1);

/* Enable the PWM Timer 2 */
DrvPWM_Enable(DRVPWM_TIMER2, 1);
}

int main(void)
{
SYSCtl_Init();
PWM_Init()

PWMA->CNR2=0xFF;
PWMA->CMR2=0x01;

while(1)
{

}
 
Any reason why you went with Nuvoton rather than another ARM-M0 with more community support, like NXP, ST, or TI? I have never heard of Nuvoton before. I downloaded their technical documentation and find it pretty difficult to follow. The description of what needs to be setup are pretty good, but descriptions of registers and their effects is not very good.

By the output not changing, what does that mean? Is there a signal, you just can't adjust it, or is there no signal at all? The most common problem for people moving to ARM is the peripheral clocks. It looks like you are enabling the PWM peripheral clock, it might need the GPIO peripheral clock enabled as well.

What are you checking the signal with? Reload of 0xFF and a duty cycle of 0x01 will be a pretty low duty cycle signal.

I can't offer anything but the most generic help, since I don't know the NUC100 or the peripheral libraries you are using.
 
Any reason why you went with Nuvoton rather than another ARM-M0 with more community support, like NXP, ST, or TI? I have never heard of Nuvoton before. I downloaded their technical documentation and find it pretty difficult to follow. The description of what needs to be setup are pretty good, but descriptions of registers and their effects is not very good.

By the output not changing, what does that mean? Is there a signal, you just can't adjust it, or is there no signal at all? The most common problem for people moving to ARM is the peripheral clocks. It looks like you are enabling the PWM peripheral clock, it might need the GPIO peripheral clock enabled as well.

What are you checking the signal with? Reload of 0xFF and a duty cycle of 0x01 will be a pretty low duty cycle signal.

I can't offer anything but the most generic help, since I don't know the NUC100 or the peripheral libraries you are using.

Thanks for the advice of your,
I chose Nuvoton as I think the price is very cheap, the price is below AVR microcontroller. Yes, you are right "descriptions of registers and their effects is not very good", I could not quickly understand and I keep repeating to learn and I still could not understand.
yes i reload if oxFF and duty cycle of 0x01, should indeed will be a pretty low duty cycle signal but in actual my led is still full bright and i try again replace the value but and again there are no change.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top