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.

这函数到底啥问题 FU*K

Other Parts Discussed in Thread: RM42L432, HALCOGEN

芯片是RM42L432,用HAlCoGen生成的代码中,在het.c中有这么一个函数

void capGetSignal(hetRAMBASE_t * hetRAM, uint32 cap, hetSIGNAL_t *signal)
{
    uint32 pwmDuty = hetRAM->Instruction[(cap << 1U) + 25U].Data;
    uint32 pwmPeriod = hetRAM->Instruction[(cap << 1U) + 26U].Data;

    //signal->duty = (uint32)(((uint32)100U * pwmDuty) / pwmPeriod);
    recPwmSignal.duty = (uint32)(((uint32)100U * pwmDuty) / pwmPeriod);

    pwmPeriod = pwmPeriod >> 7U;

    if( hetRAM == hetRAM1)
    {
        //signal->period = (float64)(((float64)pwmPeriod * (float64)640.000) / (float64)1000U);
        recPwmSignal.period = pwmPeriod * 640 / 1000U;
    }
    else
    {
        recPwmSignal.period = (float64)(((float64)pwmPeriod * (float64)800.000) / (float64)1000U);
        //signal->period = (float64)(((float64)pwmPeriod * (float64)800.000) / (float64)1000U);
    }
}

每次运行到if( hetRAM == hetRAM1)这里面之后,不管是if为真还是为假,都会跳到sys_intvecs.asm文件中的

undefEntry
    b undefEntry

我原本以为是我主函数中hetSIGNAL_t *signal这里的结构体没有分配内存,可是后来即使分配了也不能用,所以我就定义了一个全局变量recPwmSignal又试了一下。可是用这个也不行,在if那里也会跳到undefEntry那里。

所以我想问一下:

1、undefEntry是内存越界、中断向量没设置好的结果吗?

2、capGetSignal这个函数,是对对应的ca0-cap7通道PWM信号的频率和周期进行采集吗?

3、在TI v5.1.5这个编译器中,为什么没有malloc.h这个文件呢?

4、为什么if中的一句计算会使程序跳到undefEntry呢?不是float的问题,我已经改成了整型的计算,也会跳。我直接改成recPwmSignal.period = 1;也会跳到undefEntry

5、pwm cap edge三个都有getsignal,输出PWM,采集它的管脚必须是PWM吗?