Second PWM on pin 7/GPIOX_21 with 3.5" shield

Post Reply
User avatar
mad_ady
Posts: 6796
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 216 times
Been thanked: 166 times
Contact:

Second PWM on pin 7/GPIOX_21 with 3.5" shield

Unread post by mad_ady » Wed Oct 30, 2019 10:24 pm

I'm trying to add a VU7 to my C2 that has a 3.5" shield on. I also want to control this VU7's brightness via the PWM mod. I have made changes to the screen and tested it with the regular PWM pin (on pin 33) and it works.
I enabled the second PWM pin as instructed here: https://wiki.odroid.com/odroid-c2/appli ... e/gpio/pwm, except the pin used for PWM1 (pin 19) is used by the LCD script as a data pin. So, I made some changes to the dtb to move PWM1 to GPIOX_21, pin 7 which according to the schematics goes as an interrupt pin on the back of the 3.5" LCD for the RTC connector (J1, pin 4). This is what I did:

Code: Select all

#fdtput -t s /media/boot/meson64_odroidc2.dtb /pinmux/odroid_pwm1 amlogic,pins GPIOX_6 GPIOX_21
# fdtget /media/boot/meson64_odroidc2.dtb /pinmux/odroid_pwm1 amlogic,pins
GPIOX_6 GPIOX_21
Rebooted, but I don't get a PWM signal on pin 7. I do get the PWM on pin 19, and it will interfere with the 3.5" display (I'm testing on a system without it currently).

The original dtb section for pwm1 looks like this:

Code: Select all

        odroid_pwm1 {
            amlogic,setmask = <0x00000003 0x00020000 0x00000003 0x00060000>;
            amlogic,clrmask = <0x00000003 0x00000300 0x00000008 0x00000800>;
            amlogic,pins = "GPIOX_6", "GPIOX_7";
            linux,phandle = <0x00000041>;
            phandle = <0x00000041>;
        };
Haven't found other pwm1 references...

Any ideas how I can change the pin used for PWM?

If it's not possible, should I try to use a software PWM? - viewtopic.php?t=25025

joerg
Posts: 908
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Has thanked: 6 times
Been thanked: 21 times
Contact:

Re: Second PWM on pin 7/GPIOX_21 with 3.5" shield

Unread post by joerg » Thu Oct 31, 2019 2:03 am

Hi @mad_ady, as of the datasheet, at pin GPIOX_21 cannot be pwm. The pwm connected to GPIOX_7 is pwm_f and can alternatively be at GPIOY_15, but this pin is not stripped to the 40pin header. Seems that you would need to use soft pwm...

joerg
Posts: 908
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Has thanked: 6 times
Been thanked: 21 times
Contact:

Re: Second PWM on pin 7/GPIOX_21 with 3.5" shield

Unread post by joerg » Thu Oct 31, 2019 2:15 am

Ah, I just saw that eventually in the driver source code the second pwm can be changed from pwm_f to pwm_e and this would make it possible to have pwm at pin GPIOX_19 aka pin11. What I don't know is if this function pwm_e is used elsewhere.

pwm-meson.c

Code: Select all

#define PWM_MISC_REG_CD		0x2196
#define PWM_PWM_E		0x21b0
#define PWM_PWM_F		0x21b1
#define PWM_MISC_REG_EF		0x21b2
#define LED_PWM_REG0		0x21da

static int npwm = 1;
module_param(npwm, int, 0644);
MODULE_PARM_DESC(npwm , "\n odroid-c1 The number of available pwm (max 2-port)\n");

#define PWM_A   0
#define PWM_F   1
These users thanked the author joerg for the post:
mad_ady (Thu Oct 31, 2019 2:18 am)

User avatar
mad_ady
Posts: 6796
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 216 times
Been thanked: 166 times
Contact:

Re: Second PWM on pin 7/GPIOX_21 with 3.5" shield

Unread post by mad_ady » Thu Oct 31, 2019 2:43 am

Sadly, other pins are not accessible because of the 3.5" connector. I'll try software pwm, or if you have suggestions on how to tap into pwm0's pin, I could control both screens at the same time - though I'd prefer seperate controls...

Post Reply

Return to “3.5inch LCD Shield”

Who is online

Users browsing this forum: No registered users and 5 guests