完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本帖最后由 一只耳朵怪 于 2018-5-22 11:37 编辑
如何用MAP_UART_transmitData()函数发送一个字符?这个函数的第二个参数应该是什么?比如要发送一个字符‘m’,第二个参数应该是什么? |
|
相关推荐
9个回答
|
|
/! Transmits a byte from the UART Module.
//! //! param moduleInstance is the instance of the eUSCI A (UART) module. //! Valid parameters vary from part to part, but can include: //! - b EUSCI_A0_MODULE //! - b EUSCI_A1_MODULE //! - b EUSCI_A2_MODULE //! - b EUSCI_A3_MODULE //! It is important to note that for eUSCI modules, only "A" modules such //! as EUSCI_A0 can be used. "B" modules such as EUSCI_B0 do not support the //! UART mode //! param transmitData data to be transmitted from the UART module //! //! This function will place the supplied data into UART transmit data register //! to start transmission //! //! Modified register is b UCAxTXBUF //! return None. // //***************************************************************************** extern void UART_transmitData(uint32_t moduleInstance, uint_fast8_t transmitData); ------------------------------------------------------ 看该头文件解释:第一个是moduleInstance,可以选择的参数是: //! - b EUSCI_A0_MODULE //! - b EUSCI_A1_MODULE //! - b EUSCI_A2_MODULE //! - b EUSCI_A3_MODULE 第二个参数是发送的数据 |
|
|
|
所以第二个参数你就可以填写个‘m’,或者你前面定义个变量存放m,或者用指针都是可以的
|
|
|
|
volatile uint8_t TXData = 1; MAP_UART_transmitData(EUSCI_A0_MODULE, TXData); --------------------------------------------------------------------------------------- /* * ------------------------------------------- * MSP432 DriverLib - v01_04_00_18 * ------------------------------------------- * * --COPYRIGHT--,BSD,BSD * Copyright (c) 2015, 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. * --/COPYRIGHT--*//****************************************************************************** * MSP432 UART - Loopback with 48MHz DCO BRCLK * * Description: This demo connects TX to RX of the MSP432 UART * The example code shows proper initialization of registers * and interrupts to receive and transmit data. If data is incorrect P1.0 LED * is turned ON. * * MCLK = HSMCLK = SMCLK = DCO of 48MHz * * MSP432P401 * ----------------- * | | * RST -| P1.3/UCA0TXD|----| * | | | * -| | | * | P1.2/UCA0RXD|----| * | | * | P1.0|---> LED * | | * * Author: Timothy Logan*******************************************************************************//* DriverLib Includes */#include "driverlib.h"/* Standard Includes */#include |
|
|
|
我一开始也是这么写的: MAP_UART_transmitData(EUSCI_A0_MODULE, 'm');,可是在上位机上收到的字符完全不对,不知道是为什么,波特率是9600,用的是ti的12mhz的那个例程,稍微改动了一下,把接受中断里的发送函数改成了MAP_UART_transmitData(EUSCI_A0_MODULE, 'm');。难道是我的硬件有问题吗?是不是只要插上launchpad上那根u***线就好了?不需要其他的操作吧? |
|
|
|
大洼球王 发表于 2018-5-22 01:15 如果能接收到数据,却内容不对,你连续发送10次m,试试看,如果能发送,且收到若干相同的字符或乱码,那么就是你时钟配置错误。 |
|
|
|
大洼球王 发表于 2018-5-22 01:15 我也是碰到这个问题,结果发现是串口字节倒序了。比如你发送的'm'二进制是0x01101101,而电脑收到的却是0x10110110。是不是固件库有BUG啊,不知道楼主解决这个问题了不 |
|
|
|
cigudefeng 发表于 2018-5-22 01:29 TI 给的例程中串口配置为MSB,即低位先发送,而正常情况下一般使用LSB,配置的时候改成LSB就好了 |
|
|
|
哇,太感谢了。才发现的 |
|
|
|
哪数据发不出去是怎么回事,大佬们
|
|
|
|
只有小组成员才能发言,加入小组>>
351 浏览 1 评论
545 浏览 2 评论
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
790 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
660 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1140 浏览 1 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
83浏览 29评论
296浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
261浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
210浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
68浏览 13评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-28 04:30 , Processed in 1.117252 second(s), Total 96, Slave 79 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号