This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

WEC7 - trying to set PWM for backlight on AM335x

Hi everyone

I'm trying to configure the PWM for the backlight as the present one uses a GPIO pin so is either on or off.

I believe I need to configure the ECAP0 registers for Simple PWM Generation (section 15.3.3.5 of the the TI AM335x manual)

From AM33x_base_regs.h
#define AM33X_ECAP_EQEP_EPWM0_REGS_PA            0x48300000

I can't find a structure for ECAP0 so defined the following:-

typedef volatile struct
{
    unsigned long TSCTR;    //offset 0x00
    unsigned long CTRPHS;    //offset 0x04
    unsigned long CAP1;    //offset 0x08
    unsigned long CAP2;    //offset 0x0C
    unsigned long CAP3;    //offset 0x10
    unsigned long CAP4;    //offset 0x14

    unsigned char RESERVED_1[16];       //offset 0x18 to 0x28 (diff = 0x10)

    unsigned short ECCTL1;              //offset 0x28
    unsigned short ECCTL2;              //offset 0x2A
    unsigned short ECEINT;              //offset 0x2C
    unsigned short ECFLG;               //offset 0x2E
    unsigned short ECCLR;               //offset 0x30
    unsigned short ECFRC;               //offset 0x32

    unsigned char RESERVED_2[40];       //offset 0x34 to 0x5C (diff = 0x28 = 40decimal)

    unsigned long REVID;    //offset 0x5C

} ECAP_REGS;

Before starting anything too complicated I was hoping to read the REVID reg as this should be 0x44D22100.

In the gpio_backlight.cpp file I've added

#define AM33X_ECAP0_REGS_PA            AM33X_ECAP_EQEP_EPWM0_REGS_PA + 0x00000100
ECAP_REGS* pECAP_REGS = NULL;

GPIO_Backlight::Initialize()
{
    PHYSICAL_ADDRESS pa1;

    pa1.QuadPart = AM33X_ECAP0_REGS_PA;
 
 pECAP_REGS = (ECAP_REGS *)MmMapIoSpace(pa1, sizeof(ECAP_REGS), FALSE);

etc,etc

}

When I look at physical address AM33X_ECAP0_REGS_PA I get 0x48300100

When I look at Virtual address pECAP_REGS I get 0x90300100 (not sure if this is correct - how can I check?)

Actual problem:-

The problem arises when I try to use the Virtual address in GPIO_Backlight::IOControl

If I use either of the following I get an error (it does not return the correct REVID)

DWORD revID = INREG32(&pECAP_REGS->REVID); or
DWORD revID = pECAP_REGS->REVID;

I will need to rebuilt the image to get the exact error but can anyone see anything obvious in what I'm trying to do?

Thanks
Terry

  • The error I get

    PID:00400002 TID:06D20012 +GPIO_Backlight::IOControl()
    PID:00400002 TID:06D20012 dwIoControlCode = (0x00000032)
    PID:00400002 TID:06D20012 +GPIO_Backlight::IOControl() -  ECAP PAddr = 0x48300100
    PID:00400002 TID:06D20012 +GPIO_Backlight::IOControl() -  ECAP Vaddr = 0x90300100
    PID:00400002 TID:06D20012 -GPIO_Backlight::IOControl()

    PID:00400002 TID:06D20012 +GPIO_Backlight::IOControl()
    PID:00400002 TID:06D20012 dwIoControlCode = (0x0000003C)

    PID:00400002 TID:06D20012 Exception 'Data Abort' (0x4): Thread-Id=06d20012(pth=9e855270), Proc-Id=00400002(pprc=8624e5e0) 'NK.EXE', VM-active=06d00012(pprc=9e89a10c) 'BackLight_GPIO.exe'
    PID:00400002 TID:06D20012 PC=ef191794(backlight.dll+0x00001794) RA=80037254(kernel.dll+0x00008254) SP=b060fc70, BVA=00000000

    PID:00400002 TID:06D20012 Exception 'Raised Exception' (0x116): Thread-Id=06d20012(pth=9e855270), Proc-Id=00400002(pprc=8624e5e0) 'NK.EXE', VM-active=06d00012(pprc=9e89a10c) 'BackLight_GPIO.exe'
    PID:00400002 TID:06D20012 PC=eff6ee40(k.coredll.dll+0x0001ee40) RA=8003d648(kernel.dll+0x0000e648) SP=b060f378, BVA=ffffffff

  • Eventually got to the bottom of this problem - the Peripheral Clock for the PWM was not switched on.