Hello,
below, my source code just to use standard interrupt every 100 us. But when I debug and set a breakpoint in standard interrupt routine, the debugger don't stop at the breakpoint. When I download this code in the target UCD3138CC64EVM-030, ACOMP_G_THRESH has 0 as value and the adc_poll function is not executed. I don't know where is the problem. Does anyone have an idea for this problem.
Thank you for your help.
#define MAIN 1
#include "system_defines.h"
#include "cyclone_device.h"
#include "pmbus_commands.h"
#include "pmbus.h"
#include "variables.h"
#include "function_definitions.h"
#include "software_interrupts.h"
#include "cyclone_defines.h"
#include "stdio.h"
int ram_event2; // comment for hyperknob [min=2500, max=37500, step=2500]
volatile int interrupt_status;
void init_timer_interrupt(void)
{
TimerRegs.T16PWM0CMP0DAT.all = 0xffff; //Threshold to reset counter - 15.625 mHz/10 KHz.
TimerRegs.T16PWM0CMPCTRL.all = 2; //Enables compare 0 (reset) interrupt
TimerRegs.T16PWM0CNTCTRL.all = 0x00c; //PWM counter is running & enables PWM counter reset by compare action on compare 0
disable_interrupt();
disable_fast_interrupt();
interrupt_status = FaultMuxRegs.FAULTMUXINTSTAT.all;
//Configure IRQ
write_reqmask(CIMINT_ALL_PWM0_COMP);
//Configure FIQ
write_firqpr (CIMINT_ALL_FAULT_MUX);
//Enable interrupts
enable_interrupt();
enable_fast_interrupt();
}
void main()
{
if(GioRegs.FAULTIN.bit.TMS_IN == 0) //emergency backdoor - TMS is normally pulled up by external resistor
{
clear_integrity_word(); //if it's pulled down, clear checksum (integrity word)
}
init_pmbus();
init_ADC_polled();
init_timer_interrupt();
//This is necessary to make sure all interrupt status values are
//cleared.
ram_event2 = Dpwm0Regs.DPWMEV1.all; //initialize hyperknob
for(;;)
{
pmbus_handler();
Dpwm0Regs.DPWMEV1.all = ram_event2; //put hyperknob value into register
}
}
#pragma INTERRUPT(c_int00,RESET)
void c_int00(void)
{
main();
}
/////////////////////////////////////////////////////////////
/// Standard interrupt /////////////
////////////////////////////////////////////////////////////
#include "system_defines.h"
#include "cyclone_device.h"
#include "pmbus_commands.h"
#include "pmbus.h"
#include "variables.h"
#include "function_definitions.h"
#include "software_interrupts.h"
void poll_adc(void)
{
if(AdcRegs.ADCSTAT.bit.ADC_INT == 1) // Conversion complete
{
Vin = AdcRegs.ADCAVGRESULT[0].bit.RESULT;
Vout = AdcRegs.ADCAVGRESULT[1].bit.RESULT;
}
AdcRegs.ADCCTRL.bit.SW_START = 1;
}
#pragma INTERRUPT(standard_interrupt,IRQ)
void standard_interrupt(void)
{
poll_adc();
FaultMuxRegs.ACOMPCTRL3.bit.ACOMP_G_THRESH = 21;
TimerRegs.T16PWM0CMPCTRL.all = 3; //clear interrupt bit by a read/write.
}