imx28evk external signals as input HW_TIMROT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx28evk external signals as input HW_TIMROT

890 Views
FS1z
Contributor II

Hi all,

 

I've a imx28evk here. Linux is the desired OS.

 

Need to configure the HW_TIMROT Timer to trigger whenever PWM_4 changed

 

Hard to figure out how this is done. No API no Docu.

 

But on the other hand - two different kernels (pengutronix/freescale).

 

Anybody here who can give any suggestions?

 

Which is the better Version to work with?

 

Greetings and Thanks.

Tags (1)
0 Kudos
Reply
2 Replies

727 Views
FS1z
Contributor II

Hi All,

FYI

TIMROT and PWM4 input signals work like this:

// set IOMUX BANK3_PIN29 to 00=pwm_4
    dat = __raw_readl(IO_ADDRESS(PINCTRL_PHYS_ADDR + HW_PINCTRL_MUXSEL7));
    // bitmask: set bits 27/26 to 0
    __raw_writel(0xF3FFFFFF & dat, IO_ADDRESS(PINCTRL_PHYS_ADDR + HW_PINCTRL_MUXSEL7));

    printk("HW_PINCTRL_MUXSEL7    %x \n" , __raw_readl(IO_ADDRESS(PINCTRL_PHYS_ADDR + HW_PINCTRL_MUXSEL7)));

    //Enable and configure Timer3 to listen to PWM_4
    dat = __raw_readl(IO_ADDRESS(TIMROT_PHYS_ADDR + HW_TIMROT_ROTCTRL));
    // bitmask: set bits 6/4/2/0 to 1
    __raw_writel(dat | 0x00000055, IO_ADDRESS(TIMROT_PHYS_ADDR + HW_TIMROT_ROTCTRL));
    // config timrot 3
    __raw_writel(0x00004805, IO_ADDRESS(TIMROT_PHYS_ADDR + HW_TIMROT_TIMCTRLn(3)));

    printk("HW_TIMROT_ROTCTRL     %x \n", __raw_readl(IO_ADDRESS(TIMROT_PHYS_ADDR + HW_TIMROT_ROTCTRL)));
    printk("HW_TIMROT_TIMCTRLn(3) %x \n", __raw_readl(IO_ADDRESS(TIMROT_PHYS_ADDR + HW_TIMROT_TIMCTRLn(3))));

 

The count register of Timrot3 will decrease from 0xFFFFFFFF now.

 

I just wonder what happens, when the count register reaches 0x00000000?

 

Cheers,

FS

0 Kudos
Reply

727 Views
FS1z
Contributor II

Hello All,

 

so I'm trying to make usage of the TIMROT timer3 now, to read the pwm4 input.

 

While doing some further investigation and testing of the rotary timers I became confused and don't even know where to start right now.

 

So hopefully you can give me some further hints how to proceed.

 

1. So first I decided to use TIMER3. There's an example to set up the control fields for the timers in the processor ref. manual e.g. on page 1524 to use HW_TIRMOT_TIMCTRLn_WR(3, 0x00000005) to init the timer.

 

I wonder what Freescale wants to tell us with that, cause there's no occurrence of this define in the whole source!?!

 

2. So I used __raw_writel in the context of the hello_mod example to set the control registers. Wrote e.g. 0x00054b05 (PWM4 with match_mode and duty_cycle) to IO_ADDRESS(TIMROT_PHYS_ADDR + HW_TIMROT_TIMCTRL3) and that's accepted. 

Now I thought, that the timer would start to count right away, but it doesn't. 

Did a devmem2 call on all the count registers, but nothing changes. 

Also did some try and error configs to the control reg but non of them let the timer count.

Do you know, where there's the error in my logic?

 

3. So maybe I have to do another approach, which is, to make use of the timer programming interface described in chapter 3-4 of the linux ref. manual. There's the mxs_timer_init function in the arch/arm/plat-mxs/timer-match.c file and the structures clocksource and clockevent. Further the timers already get initialized in device.c. 

But this code is really confusing me and I even guess, that I won't have to touch it, just to get the rotary timer count on PWM_4 input signals. 

 

So thanks for your help and Greetings,

F

0 Kudos
Reply