How do you call set_voltage API function. Datasheet is quite vague on details...
So from datasheet:
typedef struct _PWRD {
unsigned int (*set_pll)(unsigned int mul, unsigned int inFreq);
unsigned int (*set_voltage)(unsigned intmode, unsigned int desFreq);
void (*power_mode_configure)(unsigned intmode, unsigned int peripheral);
}PWRD;
#define rom_driver_ptr (*(ROM)**) 0x03000200
pPWRD = (PWRD*)(rom_driver_ptr->pPWRD);
pPWRD->set_voltage(??, 96000000);
What I dont understand from this is,
- how is ROM defined
- what is pPWRD
- what is param0 in set_voltage. There is only description mode =0 for low power mode .. should I select some arbitrary value here ?
Thanks...
已解决! 转到解答。
Hi
LPC1549 MCU also with ROM Power control API code, there with LPCOpen [wwdt] demo also call the power control API function.
The default demo path is: ..\lpcopen_2_20_keil_iar_nxp_lpcxpresso_1549\applications\lpc15xx\iar\nxp_lpcxpresso_1549
In <romapi_15xx.h> file with below definition:
/**
* @brief LPC15XX High level ROM API structure
*/
typedef struct {
const uint32_t pUSBD; /*!< USBD API function table base address */
const uint32_t reserved0; /*!< Reserved */
const CAND_API_T *pCAND; /*!< C_CAN API function table base address */
const PWRD_API_T *pPWRD; /*!< Power API function table base address */
const uint32_t reserved1; /*!< Reserved */
const I2CD_API_T *pI2CD; /*!< I2C driver API function table base address */
const DMAD_API_T *pDMAD; /*!< DMA driver API function table base address */
const SPID_API_T *pSPID; /*!< I2C driver API function table base address */
const ADCD_API_T *pADCD; /*!< ADC driver API function table base address */
const UARTD_API_T *pUARTD; /*!< UART driver API function table base address */
} LPC_ROM_API_T;
/* Pointer to ROM API function address */
#define LPC_ROM_API_BASE_LOC 0x03000200UL
#define LPC_ROM_API (*(LPC_ROM_API_T * *) LPC_ROM_API_BASE_LOC)
So the ROM definition is similar with LPC_ROM_API_T struct.
pPWRD is Power control api function table base address;
There only with one option (low power mode) for set_voltage() function param0.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi
LPC1549 MCU also with ROM Power control API code, there with LPCOpen [wwdt] demo also call the power control API function.
The default demo path is: ..\lpcopen_2_20_keil_iar_nxp_lpcxpresso_1549\applications\lpc15xx\iar\nxp_lpcxpresso_1549
In <romapi_15xx.h> file with below definition:
/**
* @brief LPC15XX High level ROM API structure
*/
typedef struct {
const uint32_t pUSBD; /*!< USBD API function table base address */
const uint32_t reserved0; /*!< Reserved */
const CAND_API_T *pCAND; /*!< C_CAN API function table base address */
const PWRD_API_T *pPWRD; /*!< Power API function table base address */
const uint32_t reserved1; /*!< Reserved */
const I2CD_API_T *pI2CD; /*!< I2C driver API function table base address */
const DMAD_API_T *pDMAD; /*!< DMA driver API function table base address */
const SPID_API_T *pSPID; /*!< I2C driver API function table base address */
const ADCD_API_T *pADCD; /*!< ADC driver API function table base address */
const UARTD_API_T *pUARTD; /*!< UART driver API function table base address */
} LPC_ROM_API_T;
/* Pointer to ROM API function address */
#define LPC_ROM_API_BASE_LOC 0x03000200UL
#define LPC_ROM_API (*(LPC_ROM_API_T * *) LPC_ROM_API_BASE_LOC)
So the ROM definition is similar with LPC_ROM_API_T struct.
pPWRD is Power control api function table base address;
There only with one option (low power mode) for set_voltage() function param0.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks, this is what I was looking for. Exact code for LPC5410x is following:
typedef struct{ unsigned int (*set_pll)(unsigned int mul, unsigned int inFreq); unsigned int (*set_voltage)(unsigned intmode, unsigned int desFreq); void (*power_mode_configure)(unsigned intmode, unsigned int peripheral); }PWRD_API_T; typedef struct { const uint32_t reserved_usb; const uint32_t reserved_clib; const uint32_t reserved_can; const PWRD_API_T *pPWRD; const uint32_t reserved_div; const uint32_t reserved_i2cd; const uint32_t reserved_dmad; const uint32_t reserved_spid; const uint32_t reserved_adcd; const uint32_t reserved_uartd; const uint32_t reserved_vfifo; const uint32_t reserved_usart; }LPC_ROM_API_T; #define LPC_ROM_API (*(LPC_ROM_API_T * *) LPC_ROM_API_BASE_LOC) #define LPC_ROM_API_BASE_LOC 0x03000200UL
and then call from main function:
LPC_ROM_API->pPWRD->set_voltage(1, 96000000);
I am not sure what exactly did I do with set_voltage call, but it seems that my uC is now working with 96Mhz PLL setting. Without this call, it would just reset itself due to (I guess, power protection circuit or something similar).
Hi
I checked LPC5410x product with below errata info:
So, please using LPCOpen software for LPC5410x provided power_lib instead using ROM set_voltage API.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Yes i stumbled across that. So there is a bug in chip implemented API that needs workaround ? Can it be done without using the power API library? Because I am not using any libraries, only bare metal.
What can happen if I dont use the power_lib ? can I fry the chip or ?
Hi
Yes, that should be a chip bug and need using workaround way.
If there without calling the power API library, the LPC5410x could not get the correct power supply. Then the chip could not work normally.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------