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.

[参考译文] MSP430FR2355:寄存器寻址

Guru**** 2538940 points


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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/914004/msp430fr2355-register-addressing

器件型号:MSP430FR2355

我有一个函数(见下面),虽然有点难看/不干净,但效果很好……我在阅读数据表(表6-48)后不理解的是,当我尝试和实施时,所有寄存器都在偶数边界上:

*(k +(2* shft + 2))对于下面突出显示的代码,我没有获得正确的更新注册...有人能告诉我我缺少什么吗?

void pwmRemote (volatile char p、volatile boolean gate)
{
volatile unsigned int *k;
unsigned int shft;

K =&TB3CTL;//设置 TB3的基地址
对于(shft = 1;shft < 7;shft++){
IF (GATE){
如果(p >> shft)& BIT0)
*(k +(2 + shft - 1))|= OUTMOD_3;
否则{
P6OUT &=~Ω(BIT0 <<shft);
*(k +(2 + shft - 1))&=~(BIT7 | BIT6 | BIT4);
}
}
否则{
TB3CCR0 = 65535;
如果(p >> shft)& BIT0){
*(k +(shft + 1))|= OUTMOD_7;
*(k +(shft + 9))= 6554;
}
否则{
P6OUT &=~Ω(BIT0 <<shft);
*(k +(shft + 1))&=~(BIT7 | BIT6 | BIT5);
*(k +(shft + 9))= 327;
}
}

}

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

    指针算术基于指向的对象的大小。 (k +=1)与 k++相同并获得与 k[1]相同的地址。

    这是非常基本的 C 语言。