完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
UART有8个串口,UART0调试正常(有范例)但配置在UART1/2/3/4/5/6/7都不能正常通讯,不知道是怎么回事。配置了GPIO pin脚的功能还是无法通信
如题,相同代码按照uart0配置可以通信,换成uart1不行,tivac 123M4H6PM int main (void) [ char cThisChar; //SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); GPIOPinTypeUART(GPIO_PORTB_BASE,GPIO_PIN_0|GPIO_PIN_1); UARTConfigSetExpClk(UART1_BASE,SysCtlClockGet(),115200,(UART_CONFIG_WLEN_8|UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE)); UARTCharPut(UART1_BASE,'!'); do [ cThisChar=UARTCharGet(UART1_BASE); UARTCharPut(UART1_BASE,cThisChar); ]while ((cThisChar!='n')&&(cThisChar!='r')); return(0); ] |
|
相关推荐
3 个讨论
|
|
我配置串口1,没有问题
// sensor.//// Copyright (c) 2010-2017 Texas Instruments Incorporated. All rights reserved.// Software License Agreement// // 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.// // This is part of revision 2.1.4.178 of the Tiva Firmware Development Package.////*****************************************************************************#include ADC Temperature Sensor (temperature_sensor)//!//! This example shows how to setup ADC0 to read the internal temperature//! sensor.//!//! NOTE: The internal temperature sensor is not calibrated. This example//! just takes the raw temperature sensor sample and converts it using the//! equation found in the LM3S9B96 datasheet.//!//! This example uses the following peripherals and I/O signals. You must//! review these and change as needed for your own board://! - ADC0 peripheral//!//! The following UART signals are configured only for displaying console//! messages for this example. These are not required for operation of the//! ADC.//! - UART0 peripheral//! - GPIO Port A peripheral (for UART0 pins)//! - UART0RX - PA0//! - UART0TX - PA1//!//! This example uses the following interrupt handlers. To use this example//! in your own application you must add these interrupt handlers to your//! vector table.//! - None.////*****************************************************************************//*****************************************************************************//// This function sets up UART0 to be used for a console to display information// as the example is running.////*****************************************************************************voidInitConsole(void)[ // // Enable GPIO port A which is used for UART0 pins. // TODO: change this to whichever GPIO port you are using. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // // Configure the pin muxing for UART0 functions on port A0 and A1. // This step is not necessary if your part does not support pin muxing. // TODO: change this to select the port/pin you are using. // GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); // // Enable UART0 so that we can configure the clock. // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); // // Use the internal 16MHz oscillator as the UART clock source. // UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC); // // Select the alternate (UART) function for these pins. // TODO: change this to select the port/pin you are using. // GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Initialize the UART for console I/O. // UARTStdioConfig(1, 115200, 16000000);]int main(void)[ uint32_t ui32ADC0Value[4]; volatile uint32_t ui32TempAvg; volatile uint32_t ui32TempValueC; volatile uint32_t ui32TempValueF; SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); InitConsole(); // // Display the setup on the console. // UARTprintf("ADC ->n"); UARTprintf(" Type: Internal Temperature Sensorn"); UARTprintf(" Samples: Onen"); UARTprintf(" Update Rate: 250msn"); UARTprintf(" Input Pin: Internal temperature sensornn"); //5分频,使用PLL,外部晶振16M,system时钟源选择 main osc。系统时钟40MHZ SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //使能ADC0 ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); //We want to use ADC0, sample sequencer 1, //we want the processor to trigger the sequence and we want to use the highest priority ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS); //Configure steps 0 - 2 on sequencer 1 to sample the temperature sensor (ADC_CTL_TS). ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END); //Sample the temperature sensor (ADC_CTL_TS) and configure the interrupt flag (ADC_CTL_IE) //Tell the ADC logic that this is the last conversion on sequencer1 (ADC_CTL_END). ADCSequenceEnable(ADC0_BASE, 1); //enable ADC sequencer 1 while(1) [ ADCIntClear(ADC0_BASE, 1); ADCProcessorTrigger(ADC0_BASE, 1); //trigger the ADC conversion with software while(!ADCIntStatus(ADC0_BASE, 1, false)) [ ] //wait for the conversion to complete ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value); ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2)/4; //Since 2/4 = 1/2 = 0.5, 1.5 will be rounded to 2.0 with //the addition of 0.5. In the case of 1.0, when 0.5 is added to yield 1.5, this will be rounded //back down to 1.0 due to the rules of integer math.即四舍五入 ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096)/10; //TEMP = 147.5 – ((75 * (VREFP – VREFN) * ADCVALUE) / 4096) //VREFP – VREFN=3.3V ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5; UARTprintf("Temperature = %d*C or %d*Frn", ui32TempValueC, ui32TempValueF); //F = ( C * 9)/5 +32 ]]直接用的第三方的库,没用你的例程,但是肯定是可以的,继续检查细节吧。 |
|
|
|
|
|
ljmlvmd 发表于 2018-8-15 07:48 你硬件配置的时候接了跳帽或者连线吗,我检查了好久感觉代码没什么问题 |
|
|
|
|
|
只有小组成员才能发言,加入小组>>
279 浏览 1 评论
494 浏览 2 评论
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
730 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
630 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1096 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
212浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
168浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
41浏览 13评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
144浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
148浏览 12评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-12 23:33 , Processed in 1.242761 second(s), Total 67, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号