How can I control PWM block on SAMA5d3

Moderator: nferre

hmin65
Posts: 3
Joined: Sun Jul 12, 2015 11:45 pm

How can I control PWM block on SAMA5d3

Mon Jul 13, 2015 12:01 am

Hi! There.

I tried to control PWM block on SAMA5D3.
But I couldn't do that, because it is fail any value to write onto PWM registers.
My code is belows;

/***************************************/
/*        Function for PWMs            */
/***************************************/

#define PWM0_PREB           0x0a
#define PWM0_DIVB           0x01
#define PWM0_PREA           0x0a
#define PWM0_DIVA           0x01
#define PCR_PWM0_CLK        (PWM0_PREB<<24) | (PWM0_DIVA<<16) | (PWM0_PREA<<8) | PWM0_DIVA
#define PCR_PWM0_CFCH       PWM_CMR_CPRE_MCK_DIV_1024 //| PWM_CMR_CALG | PWM_CMR_CPOL | PWM_CMR_DTHI
#define PCR_PWM0_PRD        0x0200
#define PCR_PWM0_DTY        0x0100
#define PCR_PWM_WP          0x50574DFC

Pwm *pcrPWMC = PWM;

void pPWM_init(void)
{
    uint32_t i = 0x50574dfc;
    
    PIO_Configure(pcrPWM, PIO_LISTSIZE(pcrPWM));
    pPIO_Set(PCR_DC_FAN1); 

    pcrPWMC->PWM_WPCR = i; //0x50574dfc; //PCR_PWM_WP;
    
    PWMC_DisableChannel(pcrPWMC, PCR_PWM0); <--- Couldn't write onto PWM_DIS
    pcrPWMC->PWM_SCM = 0x00000000;
    pcrPWMC->PWM_OSS = 0x00000000;
    pcrPWMC->PWM_OSC = 0x00000000;
    
//    pPwm->PWM_CLK= mode;
    
    // for DC fan 1
    PWMC_ConfigureClocks(pcrPWMC, PCR_PWM0_CLK); <--- Couldn't write onto PWM_CLK
//    PWMC_EnableChannelIt(Pwm* pPwm,uint8_t channel);
//    PWMC_DisableChannelIt(Pwm* pPwm,uint8_t channel);
    PWMC_ConfigureChannel(pcrPWMC, PCR_PWM0, PCR_PWM0_CFCH); <--- Couldn't write onto PWM_CH_NUM[0].PWM_CMR
    PWMC_SetPeriod(pcrPWMC, PCR_PWM0, PCR_PWM0_PRD); <--- Couldn't write onto PWM_CH_NUM[0].PWM_CPRD
    PWMC_SetDutyCycle(pcrPWMC, PCR_PWM0, PCR_PWM0_DTY); <--- occur SWI interrupt
}

Where am I wrong?
Do i forget something?

I developed F/W without RTOS like Linux.
And i use IAR EWARM 6.50.

Thank you.
Hoon.
jharley
Posts: 238
Joined: Thu Dec 06, 2012 6:40 am

Re: How can I control PWM block on SAMA5d3

Tue Jul 14, 2015 4:28 am

did you look at the example in the software pack?
http://www.atmel.com/tools/SAMA5D3SOFTWAREPACKAGE.aspx
hmin65
Posts: 3
Joined: Sun Jul 12, 2015 11:45 pm

Re: How can I control PWM block on SAMA5d3

Tue Jul 14, 2015 3:43 pm

jharley wrote:did you look at the example in the software pack?
http://www.atmel.com/tools/SAMA5D3SOFTWAREPACKAGE.aspx
jharley.

I use IAR EWARM 6.50 with 'SAMA5D3 IAR Software Package 1.4 for Xplained Board'.
But I couldn't find any example code for PWM control on SAMA5D3x.
I could find pwmc.c & pwmc.h files.
So I called the functions in pwmc.c.
But doesn't worknig...  

How can I write a value onto the register in PWM?

Thanks jharley.
blue_z
Location: USA
Posts: 1974
Joined: Thu Apr 19, 2007 10:15 pm

Re: How can I control PWM block on SAMA5d3

Tue Jul 14, 2015 8:24 pm

hmin65 wrote:Couldn't write onto ,,,


But doesn't worknig...
Your repetitive negative descriptions provide no insight as to what is actually happening.
There's an infinite list of things that did not happen, and you're only mentioning one.
Learn how to describe a problem without using the "not" word.

Regards
Last edited by blue_z on Thu Jul 16, 2015 2:40 am, edited 1 time in total.
jharley
Posts: 238
Joined: Thu Dec 06, 2012 6:40 am

Re: How can I control PWM block on SAMA5d3

Wed Jul 15, 2015 11:00 pm

Most periperials on ARM, if not all, each have a periperal clock that is initially disabled on power up. Did you enable the periperal clock for the PWM? (see the datasheet PWM section)
CAUTION:
Before using the PWM controller, the programmer must first enable the peripheral clock in the Power Management
Controller (PMC).
I would recommend a careful review of the PWM section of the datasheet.

Best Regards
hmin65
Posts: 3
Joined: Sun Jul 12, 2015 11:45 pm

Re: How can I control PWM block on SAMA5d3

Wed Jul 29, 2015 1:31 am

Hi jharley.

I solved the problem for PWM.
The reason of the problem is caused peripheral clock.
Now PWM block works well.

Your advice is big help for me.
Thanks a lot.

Return to “SAMA5-based”

Who is online

Users browsing this forum: Google [Bot] and 2 guests