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.

[参考译文] DK-TM4C129X:在 DK-TM4C129X 中使用不同的 UART 通道时会有问题和疑问。

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/565950/dk-tm4c129x-there-are-problems-and-questions-when-using-different-uart-channels-in-dk-tm4c129x

器件型号:DK-TM4C129X

使用 uart0通过 PA0引脚获取传感器值。 但它无法使用 uart5获取它。 我不知道问题是什么。
2.是否可以使用4个传感器作为 tm4c129x? 我的文档中只有2个 UART (uart0、uart5)。 我能否找到它、或者告诉我是否需要以不同的方式分配它?

这是我的代码。

#include
#include
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"

#ifdef 调试
无效
_error__(char * pcFilename、uint32_t ui32Line)


#endif

void reverseArrayInt (int*数组、int size){
 内部温度;
 int i=0;
 对于(i = 0;i < size / 2;i++){
   temp = array[i];
   array[i]= array[(size - 1)- i];
   array[(size - 1)- i]= temp;
 }

void ConfigureUART (void){
   ROM_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOA);
   ROM_SysCtlPeripheralEnable (SYSCTL_Periph_UART0);

   ROM_GPIOPinConfigure (GPIO_PA0_U0RX);
   ROM_GPIOPinConfigure (GPIO_PA1_U0TX);
   ROM_GPIOPinTypeUART (GPIO_Porta_base、GPIO_PIN_0 | GPIO_PIN_1);

   UARTClockSourceSet (UART0_BASE、UART_CLOCK_PIOSC);
  
   UARTStdioConfig (0、115200、16000000);

char * ushortToBinary (unsigned short i){
 静态字符 s[16 + 1]={"0"、};
 INT 计数= 16;

 执行{s[--count]='0'+(char)(I 和1);
      I = I >> 1;
 } while (count);

 退货;

int main (void){
 uint32_t ui32SysClock;
 volatile uint32_t ui32Loop;
   char data_CRNT;
   int a、b、c、d、f、sum=0;
   int i=0;
   int j=0;
   int k=1;
   int Result1[8];
   int Result2[8];
   int temp8[8]={128、64、32、16、8、4、2、1};
   int temp4[4]={8、4、2、1};
   char Sync_after ='b';
   int Packet_TX_Index = 0;
   字符 Data_Prev = 0;
   CHAR PUD0 = 0;
   CHAR CRD_PUD2_PCDT = 0;
   char PUD1 = 0;
   字符 PacketCount = 0;
   char PacketCyclicData = 0;
   char psd_idx = 0;
   字符 PacketStreamData[200];

   ROM_FPULazyStackingEnable();
   ui32SysClock = SysCtlClockFreqSet ((SYSCTL_XTAL_25MHz |
                                        SYSCTL_OSC_MAIN |
                                        SYSCTL_USE_PLL |
                                        SYSCTL_CFG_VCO_480)、120000000);

   ROM_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF);
   ROM_GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE、GPIO_PIN_2);

   ConfigureUART();
   while (1){
    
     DATA_CRNT = UARTCharGet (UART0_BASE);
       
       int retv = 0;

       if (Data_Prev =255 & data_CRNT ==254)
        {
        SYNC_After ='A';
        packet_TX_Index = 0;
    
        }
       DATA_Prev = DATA_CRNT;
       如果(Sync_After ='A')
      {
        packet_tx_Index++;
        if ((int) Packet_TX_Index > 1)
        {
        IF (Packet_TX_Index = 2)
        {
        PUD0 = DATA_CRNT;
        }
        否则、如果(Packet_TX_Index = 3)
        CRD_PUD2_PCDT = DATA_CRNT;
        否则、如果(Packet_TX_Index = 4)
        {
        PacketCount = DATA_CRNT;
       
        }
        否则、如果(Packet_TX_Index = 5)
        PUD1 = DATA_CRNT;
        否则、如果(Packet_TX_Index = 6)
        {
        PacketCyclicData = DATA_CRNT;
        if ((int) PacketCount==6)
        {
        A=(int) PacketCyclicData;
        
         for (i=0;a>0;i++)
         {
          Result1[i]=a%2;
          A=A/2;
         }
        reverseArrayInt (result1、4);
        
        for (i=0;i<4;i++)
        {
             sum=sum+Result1[i]* temp4[i];
        }
       
         a=sum * 256;
         
         总和= 0;
        }


        否则 if ((int) PacketCount==7)
        {
        B=(int) PacketCyclicData;
                 
                  UARTprintf ("%d\n"、A+b);
                 
                  (int) PacketCount=0;
                  }
        }

        }
        否则、如果(Packet_TX_Index > 6)
        {
         PSD_idx =(Packet_TX_Index - 7);
         PacketStreamData[PSD_idx]= DATA_CRNT;
        }
       }
        IF (Packet_TX_Index =(16 * 2 * 12 + 6))
         {
         SYNC_After ='b';
         }
       

       }

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

    此处显示的唯一代码是 UART0代码。 另请注意、为了实现 ICDI 器件(TM4C123GH6PM)的 COM 端口仿真、UART0被连接在电路板上。 那么、您如何绕过相同的器件呢?

    同样、在代码中看不到 UART5、因此我不知道您将器件操作配置为了什么。