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: UCD3138 full bridge hard switch development board source code

Part Number: UCD3138

Hello, I have recently learned UCD3138 full bridge hard switch development board source code.

I  would like to ask two questions.

The first question: why the function “void swi_single_entry (Uint32 arg1, Uint32 arg2, Uint32 arg3, Uint8 swi_number) ”and function “void software_interrupt (Uint32 arg1, Uint32 arg2, Uint32 arg3, Uint8 swi_number) function” name is not the same, but the content can be mutually transfer?

The second question: MiscAnalogRegs.CSTRIM.bit.RESISTOR_TRIM = 23; I can not find a detailed description of the register CSTRIM in the manual, where can I find?

thanks.

  • On the first question, the mutual transfer is done by the c compiler. There's a pragma that enables you to map multiple function calls to the software interrupt instruction. The ARM7 has a software interrupt instruction that accepts an 8 bit code, and the pragma lets you associate up to 256 different functions with the software interrupt.

    So it when you type the function name, it will push the other parameters on the stack and then issue a software interrupt instruction with the right 8 bit value.

    With CCS 3, we could do a trick, and get that value to appear as an arg. Our trick stopped working in CCS 6, so we just send the interrupt number as a regular arg.

    But we still use the software interrupt to go to privileged mode to do dangerous things we can't do in user mode.

    Your second question - that trim register is set in the factory, and the value is different for each chip. It's in there to trim for production variation. That why we don't normally disclose it. I'm going to have to ask about that one.
  • Thank you very much!
    Zouyang
  • Hello, I am having a problem.
    Look at the following code:

    void configure_pgood_levels(void)
    {
    pmbus_dcdc_config_translated[0].pgood_on_limit = (constant_145_211, pmbus_dcdc_config[0].pgood_on_limit, -VOUT_MODE_EXP, MAX_VALUE_FIT_12_BITS);
    pmbus_dcdc_config_translated[0].pgood_off_limit =qnote_linear16_multiply_fit(constant_145_211,pmbus_dcdc_config[0].pgood_off_limit, -VOUT_MODE_EXP, MAX_VALUE_FIT_12_BITS);
    }

    Why is the first statement omitted "qnote_linear16_multiply_fit", so that the statement is correct?
    How does get the constant 145.211?

    thanks.
  • Hello, I have a problem.
    Look at the following code:
    Void configure_cpcc (void)
    {
    Struct qnote constant_316_46 = {26253, -6};
    }
    I understand constant_316_46 = 26253 / 2e6 = 26253/64 = 410.20 instead of 316.46.
    So is this expression wrong? Is it supposed to be written as struct qnote constant_410_20 = {26253, -6}? Or are I wrong?
  • Hello, I found scale.c in the source file is the data zoom function.

    Such as Uint32 qnote_linear11_multiply_fit (struct qnote x, int16 linear11, Uint32 max_value), Uint32 qnote_linear16_multiply_fit (struct qnote x, Uint16 linear16_mantissa, int8 vout_mode, Uint32 max_value), struct qnote qnote_scale (struct qnote x, int16 y).

    I am a novice, I do not understand the data zoom.
    Is there a relevant document to introduce these data zoom function? Or what documents should I learn in order to understand the scale.c file function?
  • qnote format is a home made floating point that we used to avoid the overhead of full floating point calculations. The qnote struct is like this:

    struct qnote
    {
    int16 mantissa;
    int16 exponent;
    };

    If you are familiar with floating point, that should make things more clear.

    If you aren't familiar with floating point, there is lots of good information on the web.

    To generate qnote numbers, use the UCD3xxx device GUI. Click on the utilities tab, and then click on the mantissa/exponent tool. This tool can convert back and forth between floating point numbers and qnote format. That's the conversion tool.

    The rest of the generation for the conversion depends on what you are doing. Generally it's used to translate between some measured value outside the UCD - voltage, temperature, current - to an internal value, typically from an ADC.

    There are several factors in the equation:

    1. External divider, for example a voltage divider that divides by 200
    2. Voltage step for 1 ADC step, which is 2.5/4096 = 0.000610. (this is the range of the ADC divided by the number of steps)

    So if you multiply the two together, you get the voltage step before the divder required for a single ADC step - 0.1220.

    If you multiply times this number, you'll translate from raw ADC value to voltage.

    To convert from voltage to ADC, you don't want to do a divide, because that will take much longer.

    Instead multiply times the reciprocal of the number
  • Thank you very much!