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.

[参考译文] MSP432P401R:将 P6.7引脚初始化为 TA2.4的 PWM 功能、从而影响 SPI 接收 UCB3的数据

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/788310/msp432p401r-initialize-the-p6-7-pin-to-the-pwm-function-of-ta2-4-affecting-the-spi-receiving-data-of-ucb3

器件型号:MSP432P401R

你(们)好  

使用 UCB3模块的 SPI 功能:将 P10.3配置为 SOMI、将 P10.2配置为 SIMO、将 P10.1配置为 SCK;时钟频率为12M;

初始化代码如下所示:

P10SEL1 &= ~(BIT2+ BIT3);

P10SEL0 |= (BIT2+ BIT3);

P10SEL0 |= (BIT1);

P10SEL1 &= ~(BIT1);

P10DIR |=  BIT1;

P10SEL0 &= ~(BIT0);

P10SEL1 &= ~(BIT0);

P10DIR |=  BIT0;

P9SEL0 &= ~(BIT7);

P9SEL1 &= ~(BIT7);

P9DIR |=  BIT7;

UCB3CTLW0 |= UCSWRST;

UCB3CTLW0 |= (UCMST + UCSYNC  + UCMSB+  UCCKPL);     

UCB3CTLW0 |= UCSSEL_2;

UCB3BRW = 2;

UCB3CTLW0 &= ~UCSWRST;

TA2.4被配置为 PWM 功能、输出引脚 P6.7、配置输出功能第一个基本功能;输出频率100Hz、计数模式2;

初始化代码如下所示:

    P6SEL0 |= BIT7;

P6SEL1 &= ~BIT7;

P6DIR |= BIT7;

P6OUT |= BIT7;

TA2CTL &= ~(MC1 + MC0 ) ;

 

TA2CTL |= TASSEL_2 + TACLR + ID_3;

TA2CCR0 = SMCLK/800  ;

TA2CCR4 = 0x0;

TA2CCTL4 = OUTMOD_2;  

TA2CTL |= MC0;

如果 PWM 函数未初始化、则 SPI 操作正常;但是、在 PWM 初始化后、SPI 的读取数据始终为0xff;

我是否可以知道这一切是关于什么?

谢谢