Tool/software: Code Composer Studio
Hello,
Below is my code which just wants to use an interrupt to change the duty cycle of PWM.
I have two questions.
1. The GUI reports this:
22:38:46.655 No ROM detected: read block error while getting ROM version
when I add this sentence CimRegs.FIRQPR.bit.FIRQ_DPWM0 = 1; // set to FIQ mode (Red in the code below).
2. If I exclude this sentence, just a fixed duty cycle of PWM can work. Even in this condition, the UCD3138 cannot stay in ROM. The GUI reports that
22:45:03.153 Found DC-DC HSFB Firmware v0.0.11.105 @ Address 88d in program mode
But, I want it to work in ROM mode so that I can use the memory debug.
Could you tell me how to solve this problem? Thank you so much!!!
#define MAIN 1
#include "system_defines.h"
#include "Cyclone_Device.h"
#include "pmbus_commands.h"
#include "pmbus_common.h"
#include "pmbus_topology.h"
#include "variables.h"
#include "functions.h"
#include "software_interrupts.h"
#include "cyclone_defines.h"
#include "stdio.h"
#define PCLK_PERIOD 4.0e-9
#define PERIOD_SECONDS 10.0e-6
#define PERIOD ((int)(PERIOD_SECONDS/PCLK_PERIOD)<<4)
#define EVENT1 (int)(PERIOD*0.2)
float temp= 0.2;
void init_dpwm0(void)
{
Dpwm0Regs.DPWMCTRL0.bit.PWM_EN = 0; // disable DPWM0 locally during initilization
Dpwm0Regs.DPWMCTRL0.bit.CLA_EN = 0; // default is 1 (i.e. default is to use the filter output to control DPWM)
Dpwm0Regs.DPWMPRD.all = PERIOD; // use .all for all values, so that the scaling matches
Dpwm0Regs.DPWMEV1.all = EVENT1; // set EVENT 1 to 0% (start) of period
Dpwm0Regs.DPWMINT.bit.PRD_INT_EN = 1; //open DPWM0 interrupt
Dpwm0Regs.DPWMINT.bit.PRD_INT_SCALE = 0011; //Period Interrupt generated once every 6 switching cycles
CimRegs.FIRQPR.bit.FIRQ_DPWM0 = 1; // set to FIQ mode
Dpwm0Regs.DPWMCTRL0.bit.PWM_EN = 1; // enable DPWM0 locally
LoopMuxRegs.GLBEN.bit.DPWM0_EN = 1; // enable DPWM0 globally
}
void main()
{
if(GioRegs.FAULTIN.bit.FLT3_IN == 0)
{
clear_integrity_word();
}
init_pmbus(0x58); // initialize PMBus handler
init_dpwm0(); // initialize DPWM0
for(;;)
{
pmbus_handler();
}
}
#pragma INTERRUPT(c_int00,RESET)
void c_int00(void)
{
main();
}
#pragma INTERRUPT(ADCValueGet,FIQ)
void ADCValueGet(void)
{
temp=temp+0.01;
if(temp>0.9)
{
temp=0.2;
}
Dpwm0Regs.DPWMEV1.all = temp*PERIOD;
Dpwm0Regs.DPWMINT.bit.PRD = 0; //clear the flag
//from the pdf: read_scrap = Dpwm3Regs.DPWMINT.bit.PRD;
}