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.

UCD3138: timerinit problem UCD3138

Part Number: UCD3138

Hello!
I have got not expected end of program in alarm mode during execution of SWI asm command.
This command execute in init_timer_interrupt() -> disable_fast_interrupt() -> swi_single_entry(0,0,0,5).
Can somebody explain what the reason can be?, please
My code is:

~~~

#define MAIN 1

#include "include.h"
// software_interrupt_wrapper.c
void disable_fast_interrupt(void)
{
swi_single_entry(0,0,0,5); //code is 5;
}

// init_miscellaneous.c
void init_timer_interrupt(void)
{
TimerRegs.T16PWM0CMP0DAT.all = 1587; //approx 10KHz. by spec
TimerRegs.T16PWM0CMP1DAT.all = 0xffff;
TimerRegs.T16PWM0CMPCTRL.all = 2;
TimerRegs.T16PWM0CNTCTRL.all = 0x00c;

disable_fast_interrupt(); //make sure fast interrupt is disabled
disable_interrupt();
write_firqpr (0x0A000000); //make them all irqs except FAULT_INT, DPWM2
write_reqmask(0x0A020000); //enable FAULT_INT and PWM0_INT, DPWM2
enable_interrupt();
enable_fast_interrupt(); //make sure fast interrupt is enabled, enabled in Idle state
}


void main()
{
MiscAnalogRegs.IOMUX.all = 0; //enable JTAG
start_state =5;

MiscAnalogRegs.GLBIOEN.all = MASK_PGOOD | MASK_PSON | MASK_FAILURE | MASK_AC_FAIL_IN | MASK_AC_FAIL_OUT | MASK_OR_CTRL;

if ((MiscAnalogRegs.GLBIOREAD.all & MASK_PGOOD) && (MiscAnalogRegs.GLBIOREAD.all & MASK_FAILURE ) )
{
//pmbus_read_write_rom_mode(PMBUS_WRITE);
}


//Check to see if the last DFLASH erase was interrupted
look_for_interrupted_dflash_erase();

restore_default_all();

period = (SWITCH_FREQ_NUMERATOR / pmbus_dcdc_config[0].switching_frequency); // in 4 ns

configure_cpcc();

init_uart1();

init_gpio();

init_pmbus(0x58);

init_dpwm();

#if defined(UCD3138A64) || defined(UCD3138128) || defined(UCD3138A64A) || defined(UCD3138128A)
enable_oversampling();
#endif

init_adc12();

init_protection();

init_voltage_loop();

init_current_loop();

init_light_load_configuration();

init_miscellaneous();

init_timer_interrupt();

for(;;)
{


if (erase_segment_counter > 0)
{
erase_task(); // Handle the DFlash segment erases
}

decimal_out_5_digits(supply_state);
char_out('\r');
char_out('\n');
}
}

void c_int00(void)
{
main();
}

~~~

  • Ivan, that's a tough one.  I've never seen a problem with the disable timer interrupt before.  Most likely the user stack is not getting initialized to the proper value?  

    The SWI uses the supervisor stack, which is initialized in load.asm, typically like this:


    LDR r13, c_sup_stack_top ; initialize supervisor stack pointer

    Getting a good value in there it's also necessary for these statements to be in load.asm:

    SUP_STACK_TOP .equ 0x19ffc ;Supervisor mode (SWI stack) starts at top of memory

    c_sup_stack_top .long SUP_STACK_TOP

    You also need to keep this in main.c:

    void c_int00(void)
    {
    main();
    }

    If that's not there, the compiler will put in its own initialization code and may not use load.asm.  

    What have you started from?  Did you start with one of our EVM codes?  Did is work as it came from the website?  What version of CCS are you using?  I strongly suggest 6.2, especially if you are having these kinds of problems.  The initialization sequence is one of those things that can change from version to version.  

  • Thank you for reply!

    Ive got CCS 6.2 already and I started from main

    Sorry I didnt understand how can I increase the stack value

    Thanks in advance

  • Ivan, I don't understand the question.  Have you solved your issue?  

    To increase the stack value, you change the various stack constants in the load.asm file.  They are not connected to the cyclone.cmd file, so you should probably make the total stack section size match the expected stack usage based on your code and the stack values in load.asm.

    First, though, the stack in the EVM code is correct.  I suggest you use the standard program, and make sure you get that working.  

    Some people see similar issues to yours because they disregard the hardware backdoor at the beginning of main.c.  You didn't tell me what code you are using, so I can't tell you exactly which pins to pull up or down, but if you look, it should be easy to see.  It's designed to clear the flash checksum and reset the UCD, and the codes all do it by causing an exception.  

    I assume that is what you mean by unexpected end of program in alarm mode. although more detail would be helpful.  Are you getting and exception?  

    I gave some information on a recent E2E post about a similar issue here:  https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/1031362/ucd3138a-abort_prefetch_exception-interrupt-as-soon-as-miscanalogregs-iomux-all-0-is-executed

    Perhaps that will be helpful.