No PWM output on PA11 pin on SAM4S Xplain Board

Moderator: nferre

osa
Posts: 4
Joined: Sun Mar 09, 2014 10:35 pm

No PWM output on PA11 pin on SAM4S Xplain Board

Wed Mar 12, 2014 12:42 pm

Hello all,

my name is Sebastian, I am new on this forum but not new in the programming and developing low to middle complexity projects with microcontrollers.
The reason I am writing on this forum is to ask for your help regarding setting a PWM on a SAM4S Xplain board. I searched for my topic on the discussion board, but I didn’t find an appropriate topic for this.

For the beginning I want to output a PWM signal on pin PA11 (J3 Connector from the board, pin2).
From the Datasheet of the microcontroller I figured out that this pin is tied to Peripheral B.

In the following lines I copy the code I wrote for setting the PWM:

PIOB->PIO_PER=0x00000000;
PIOB->PIO_PDR=0x00000800; // enable PWM
PIOB->PIO_IER=0x00000000; // disable interrupts
PIOB->PIO_IDR=0xFFFFFFFF;
PIOB->PIO_ABCDSR[0]= 0x00000800; // assign pin to peripheral B
PIOB->PIO_ABCDSR[1]=0x00000000;
PIOB->PUDR=0x00000800;

pwm_pmc = PMC->PMC_PCSR0;
PMC->PMC_PCER0 = pwm_pmc|(0x80000000); //Enable PWM clock

PWM->PWM_CH_NUM[0].PWM_CMR = 0x0000000A; // PWM clock=MCK/1024
PWM->PWM_CH_NUM[0].PWM_CPRD = 0x000000EA; // PWM0 period=20ms
PWM->PWM_CH_NUM[0].PWM_CDTY = 0x00000075; // PWM0 duty cycle=50%
PWM->PWM_ENA = 0x00000001; // enable PWM0 output

In debug mode, I see that the register PWM_CCNT for channel 0 is updating and overflowing.
But, the corresponding pin (PA11) is always on level high. I am checking it with an oscilloscope.

Thanks for all of you for your help.

Greetings,
Sebastian.
seanfalloy
Posts: 11
Joined: Tue Sep 27, 2011 6:51 pm

Re: No PWM output on PA11 pin on SAM4S Xplain Board

Thu Mar 13, 2014 8:04 pm

I have not worked with that chip at all but I would imagine there would be alot of similarities between the modules.

-you may want to check the values of the OOV regs and OSS regs as those asynchronous override the outputs.

Also for portability reasons I would recommend using the ASF provided driver for the pwm module.

It gives you options like.
-pwm_channel_init()
-pwm_channel_enable()

and so on.... Its a bit of a headache to figure out but once you do it works fairly well.
seanfalloy
Posts: 11
Joined: Tue Sep 27, 2011 6:51 pm

Re: No PWM output on PA11 pin on SAM4S Xplain Board

Fri Mar 14, 2014 6:27 pm

I had one other thought. If you toggle the pin through the PIO interface and see if its still connected to the PIO controller. Then something in your config is not working right.
osa
Posts: 4
Joined: Sun Mar 09, 2014 10:35 pm

Re: No PWM output on PA11 pin on SAM4S Xplain Board

Mon Mar 17, 2014 2:26 pm

Hello,

I managed to find the error: PA11 is a PIOA and not PIOB pin.

Greetings,
Sebastian.

Return to “SAM9-based”

Who is online

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