TI中文支持网
TI专业的中文技术问题搜集分享网站

麻烦提供一个FR4133的串口通讯程序呢,谢谢,ti给的两个都不管用,想在32768kz下,9600通讯就行,低功耗3模式

麻烦提供一个FR4133的串口通讯程序呢,谢谢,ti给的两个都不管用,想在32768kz下,9600通讯就行,低功耗3模式

ti的两个都没有接收到

同时感觉不是低功耗的例子,

以前的其他430通讯程序不管用了

谢谢

xiaolong wei:

我自己写了个试了试也不行:

UCA0CTLW0 =0X20

UCA0BR0=0X3

UCA0MCTLW = 0X9200 

我直接写入  txbuf 一个数据  pc没有接到

pc发 单片机也没有收到

xiaolong wei:

回复 xiaolong wei:

不好意思

刚才试了  msp430fr413x_euscia0_uart_01.c

这个能通讯的,但是耗电量太大了  20ua以上!!

怎么才能低功耗呢

是不是只有时钟降低?

麻烦帮忙给个低功耗的例子程序,谢谢

xiaolong wei:

回复 xiaolong wei:

问题是

关于串口的两个时钟源  UCLK     MODCLK 究竟是啥

ACLK怎么才能用上,32768的晶体频率怎么用于串口通讯

是不是不能用?????

灰小子:

回复 xiaolong wei:

楼主你好。你的问题解决了吗?

我看了这个例程,里面用的就是ACLK = 32768Hz,不过是用的片上的RC振荡器。MCLK 和SMCLK 配置为了8MHz。

 

Yan LI8:

回复 xiaolong wei:

楼主你的那个可以正常通信的大电量c程序在哪找的啊?

Ling Zhu2:

回复 Yan LI8:

见附件。

TI 官网下载 MSP430Ware 里面包含 所有的示例代码。

kqian0327:

你好,

MSP430FR4133的寄存器和MSP43F,G都略有区别。

你可以下载MSP430WARE,里面有千千万万的例程供你参考。

我把相应例程粘贴出来供你参考。

C:\ti\msp\MSPWare_2_40_00_37\examples\devices\MSP430FR2xx_4xx\MSP430FR413x_MSP430FR203x_Code_Examples\C

/* –COPYRIGHT–,BSD_EX* Copyright (c) 2014, Texas Instruments Incorporated* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** * Redistributions of source code must retain the above copyright* notice, this list of conditions and the following disclaimer.** * Redistributions in binary form must reproduce the above copyright* notice, this list of conditions and the following disclaimer in the* documentation and/or other materials provided with the distribution.** * Neither the name of Texas Instruments Incorporated nor the names of* its contributors may be used to endorse or promote products derived* from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.********************************************************************************* * MSP430 CODE EXAMPLE DISCLAIMER** MSP430 code examples are self-contained low-level programs that typically* demonstrate a single peripheral function or device feature in a highly* concise manner. For this the code may rely on the device's power-on default* register values and settings such as the clock configuration and care must* be taken when combining code from several examples to avoid potential side* effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware* for an API functional library-approach to peripheral configuration.** –/COPYRIGHT–*///******************************************************************************// MSP430FR413x Demo – eUSCI_A0 UART echo at 9600 baud using BRCLK = 8MHz//// Description: This demo echoes back characters received via a PC serial port.// SMCLK/ DCO is used as a clock source and the device is put in LPM3// The auto-clock enable feature is used by the eUSCI and SMCLK is turned off// when the UART is idle and turned on when a receive edge is detected.// Note that level shifter hardware is needed to shift between RS232 and MSP// voltage levels.//// The example code shows proper initialization of registers// and interrupts to receive and transmit data.// To test code in LPM3, disconnect the debugger.//// ACLK = REFO = 32768Hz, MCLK = DCODIV = SMCLK = 8MHz.//// MSP430FR4133// —————–// /|\| |// | | |// –|RST |// | |// | |// | P1.0/UCA0TXD|—-> PC (echo)// | P1.1/UCA0RXD|<—- PC// | |//// Darren Lu// Texas Instruments Inc.// June 2014// Built with IAR Embedded Workbench v6.10 & Code Composer Studio v6.0//******************************************************************************

#include <msp430.h>

void Init_GPIO();

int main(void){WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

// Configure GPIOInit_GPIO();PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode// to activate 1previously configured port settings

__bis_SR_register(SCG0); // disable FLLCSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference sourceCSCTL0 = 0; // clear DCO and MOD registersCSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits firstCSCTL1 |= DCORSEL_3; // Set DCO = 8MHzCSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz__delay_cycles(3);__bic_SR_register(SCG0); // enable FLLwhile(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // Poll until FLL is locked

CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz// default DCODIV as MCLK and SMCLK source

// Configure UART pinsP1SEL0 |= BIT0 | BIT1; // set 2-UART pin as second function

// Configure UARTUCA0CTLW0 |= UCSWRST;UCA0CTLW0 |= UCSSEL__SMCLK;// Baud Rate calculation// 8000000/(16*9600) = 52.083// Fractional portion = 0.083// User's Guide Table 14-4: UCBRSx = 0x49// UCBRFx = int ( (52.083-52)*16) = 1UCA0BR0 = 52; // 8000000/16/9600UCA0BR1 = 0x00;UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_1;

UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCIUCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register(LPM3_bits|GIE); // Enter LPM3, interrupts enabled__no_operation(); // For debugger}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)#pragma vector=USCI_A0_VECTOR__interrupt void USCI_A0_ISR(void)#elif defined(__GNUC__)void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)#else#error Compiler not supported!#endif{switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG)){case USCI_NONE: break;case USCI_UART_UCRXIFG:while(!(UCA0IFG&UCTXIFG));UCA0TXBUF = UCA0RXBUF;__no_operation();break;case USCI_UART_UCTXIFG: break;case USCI_UART_UCSTTIFG: break;case USCI_UART_UCTXCPTIFG: break;default: break;}}

void Init_GPIO(){P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF;P5DIR = 0xFF; P6DIR = 0xFF; P7DIR = 0xFF; P8DIR = 0xFF;P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF;P5REN = 0xFF; P6REN = 0xFF; P7REN = 0xFF; P8REN = 0xFF;P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00;P5OUT = 0x00; P6OUT = 0x00; P7OUT = 0x00; P8OUT = 0x00;}/* –COPYRIGHT–,BSD_EX* Copyright (c) 2014, Texas Instruments Incorporated* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** * Redistributions of source code must retain the above copyright* notice, this list of conditions and the following disclaimer.** * Redistributions in binary form must reproduce the above copyright* notice, this list of conditions and the following disclaimer in the* documentation and/or other materials provided with the distribution.** * Neither the name of Texas Instruments Incorporated nor the names of* its contributors may be used to endorse or promote products derived* from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.********************************************************************************* * MSP430 CODE EXAMPLE DISCLAIMER** MSP430 code examples are self-contained low-level programs that typically* demonstrate a single peripheral function or device feature in a highly* concise manner. For this the code may rely on the device's power-on default* register values and settings such as the clock configuration and care must* be taken when combining code from several examples to avoid potential side* effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware* for an API functional library-approach to peripheral configuration.** –/COPYRIGHT–*///******************************************************************************// MSP430FR413x Demo – eUSCI_A0 UART echo at 9600 baud using BRCLK = 8MHz//// Description: This demo echoes back characters received via a PC serial port.// SMCLK/ DCO is used as a clock source and the device is put in LPM3// The auto-clock enable feature is used by the eUSCI and SMCLK is turned off// when the UART is idle and turned on when a receive edge is detected.// Note that level shifter hardware is needed to shift between RS232 and MSP// voltage levels.//// The example code shows proper initialization of registers// and interrupts to receive and transmit data.// To test code in LPM3, disconnect the debugger.//// ACLK = REFO = 32768Hz, MCLK = DCODIV = SMCLK = 8MHz.//// MSP430FR4133// —————–// /|\| |// | | |// –|RST |// | |// | |// | P1.0/UCA0TXD|—-> PC (echo)// | P1.1/UCA0RXD|<—- PC// | |//// Darren Lu// Texas Instruments Inc.// June 2014// Built with IAR Embedded Workbench v6.10 & Code Composer Studio v6.0//******************************************************************************

#include <msp430.h>

void Init_GPIO();

int main(void){WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

// Configure GPIOInit_GPIO();PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode// to activate 1previously configured port settings

__bis_SR_register(SCG0); // disable FLLCSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference sourceCSCTL0 = 0; // clear DCO and MOD registersCSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits firstCSCTL1 |= DCORSEL_3; // Set DCO = 8MHzCSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz__delay_cycles(3);__bic_SR_register(SCG0); // enable FLLwhile(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // Poll until FLL is locked

CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz// default DCODIV as MCLK and SMCLK source

// Configure UART pinsP1SEL0 |= BIT0 | BIT1; // set 2-UART pin as second function

// Configure UARTUCA0CTLW0 |= UCSWRST;UCA0CTLW0 |= UCSSEL__SMCLK;// Baud Rate calculation// 8000000/(16*9600) = 52.083// Fractional portion = 0.083// User's Guide Table 14-4: UCBRSx = 0x49// UCBRFx = int ( (52.083-52)*16) = 1UCA0BR0 = 52; // 8000000/16/9600UCA0BR1 = 0x00;UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_1;

UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCIUCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register(LPM3_bits|GIE); // Enter LPM3, interrupts enabled__no_operation(); // For debugger}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)#pragma vector=USCI_A0_VECTOR__interrupt void USCI_A0_ISR(void)#elif defined(__GNUC__)void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)#else#error Compiler not supported!#endif{switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG)){case USCI_NONE: break;case USCI_UART_UCRXIFG:while(!(UCA0IFG&UCTXIFG));UCA0TXBUF = UCA0RXBUF;__no_operation();break;case USCI_UART_UCTXIFG: break;case USCI_UART_UCSTTIFG: break;case USCI_UART_UCTXCPTIFG: break;default: break;}}

void Init_GPIO(){P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF;P5DIR = 0xFF; P6DIR = 0xFF; P7DIR = 0xFF; P8DIR = 0xFF;P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF;P5REN = 0xFF; P6REN = 0xFF; P7REN = 0xFF; P8REN = 0xFF;P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00;P5OUT = 0x00; P6OUT = 0x00; P7OUT = 0x00; P8OUT = 0x00;}

灰小子:

回复 kqian0327:

也可以使用在线版的mspware查看例程

http://www.ti.com/tirex/MSPWare

赞(0)
未经允许不得转载:TI中文支持网 » 麻烦提供一个FR4133的串口通讯程序呢,谢谢,ti给的两个都不管用,想在32768kz下,9600通讯就行,低功耗3模式
分享到: 更多 (0)