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