Thread (17 messages) 17 messages, 4 authors, 2009-08-31

AT91SAM9260: How to output PCK0 clock on a GPIO pin

flat view

From: Pedro I. Sanchez <hidden>
Date: 2009-08-31 20:46:18

On Tue, 01 Sep 2009 08:33:54 +1200, Ryan Mallon [off-list ref]
wrote:
Pedro I. Sanchez wrote:
quoted
On Mon, 31 Aug 2009 23:33:12 +0400, Sergey Matyukevich
[off-list ref]
wrote:
quoted
Hi,
 
quoted
And how do I turn on the PMC clocks for the GPIO?
Assigning gpio pin PC6 to TIOB2 peripheral is only a part of the work.
Timer counters may operate in different modes. Take a look at
the datasheet for at91sam9260, timer counters are covered in chapter
34.
quoted
quoted
It looks like 'waveform mode' is what you need (see 34.5.10, 34.5.11).
Before you get desired output on PC6 pin you will have to turn on
waveform operating mode for TIOB2 and to configure its wave shapes.
 
Thanks,
Sergey
Thanks Sergey,

So are the following statements correct?

1. The pck0 clock I've been playing with has nothing to do with the
clock
quoted
I
want on PC6 (TIOB2).

2. I have to use instead the "tc2_clk" as defined in
arch/arm/mach-at-91/at91sam9260.c.

3. I have to access the TC_CMR register directly to set things up. I
mean,
there are no macros already defined to access these structures.
Attached is a driver for outputting pwm's using the timer counters on
the at91 (sorry its not a proper patch, but this is just hauled out of
an old kernel we have). The driver is written for the 2.6.20 and does
not use the new at91 timer counter library. I think it should be
reasonably easy to port  to the mainline kernel (if you want to do this
for mainline inclusion, I'm happy to lend a hand).

To output a pwm on PC6, add the following code to your board file:

static struct at91_pwm_data pwm_data[] = {
	{
		.channel	= 2,
		.clock_div	= AT91_TC_SCLK,
		.period		= 500000,	/* Milliseconds */
		.tiob_duty	= 50,		/* Percentage */
		.tio		= AT91_TIOB,
	},
};

and in your board init function:

at91_add_device_pwm(pwm_data, ARRAY_SIZE(pwm_data));

The driver also exports the period, duty and raw ra, rb and rc counter
values via sysfs.

HTH,
~Ryan
Thank you Ryan! I'll take a look at this as I move into the TC world.

BTW, I found this thread that talks about setting a pulse signal on the TC
pins:

http://www.at91.com/samphpbb/viewtopic.php?f=12&t=18294

This is going to help me as well.


-- 
Pedro
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help