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.

[参考译文] MSP430F6779:我是否需要在此处实现多线程之类的功能?

Guru**** 2394305 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/875537/msp430f6779-do-i-need-to-implement-something-like-multithreading-here

器件型号:MSP430F6779

因此、我将从同时运行两个线程的原因开始。 我需要在特定引脚上生成 SPWM、同时继续检查与生成的 PWM 直接相关的各种 ADC 值、然后计算大量值并将这些计算值打印到 LCD 屏幕。 我使用此代码生成 SPWM 并检查 ADC 值和计算  

void main (void)

{
//停止看门狗计时器以防止超时复位
WDTCTL = WDTPW + WDTHOLD;

int Duty_cycle[]=
{2、4、7、9、13、18、20、22、22、27、33、40、44、44、44、4、4、49、51、51、51、51、51、65、65、62、62、65、62、62、65、62、62、68、67、72、72、22、22、22、22、22、22、22、14、14、14、14、22、14、14、14、22、14、14、14、22、14、22、14、14、14、22、14、14、14、14、14、14、14、14、14、14、14、14、14、22、14、14、14、14、22、14、14、22、14、14、14、14、14、14、14、14、22、14、14、14、14、22、14、14、14、14、14、14、22







for (int i=0;i<360;i++)//生成 PWM 1.
{
//TA0CCR2 = 0;
TA0CCR0 |=定时器_PERIOD;
TA0CCR2 = Duty_cycle[i];
}
CT2=READ_ADC_VALUES (4);
}


}float READ_ADC_VALUES (int array_index)
{
results[array_index]= SD24_B_getResults (SD24_BASE、
array_index);
while (results[array_index]<8392586 || results[array_index]>8430180)//过零检测
{
// count++;
results[array_index]= SD24_B_getResults (SD24_BASE、
array_index);
if (results[array_index]>peak_conversion [array_index])
peak_conversion [array_index]=results[array_index];
RMS_value=peak_convation[array_index]*0.00003973532251036290 - 332.8842284;
}
返回 rms_value;

}

我还需要监控许多其他东西、这只是一个 ADC 值。  我需要在整个代码中生成 PWM。 因为在我检查各种 ADC 值、执行复杂计算并在运行代码时在 LCD 屏幕上显示值时、它不应停止。 我该在这里做什么? 我需要您的帮助。 我是否需要在此处实施多线程? 是否有任何方法可以生成具有可变占空比(SPWM)的连续 PWM? 我写了一段代码、用于在特定引脚上生成 SPWM、它将在整个代码运行时生成 SPWM。 谢谢

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、耐受、

    您应该在不进行 CPU 交互的情况下利用独立模块功能。 可以像您一样设置计时器并生成 PWM。 如果您需要持续更改 PWM、可以利用 DMA 将数据传输到相应的定时器寄存器。 这将为您提供 CPU 时间、但是它也将分配 MAB 和 MDB 上的总线负载。

    ADC 可以设置为在不轮询的情况下进行测量、并且仅在出现中断时需要 CPU 交互。

    希望这对您有所帮助。