打印
[其他ST产品]

str731串口初始化问题?

[复制链接]
1869|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ligang411|  楼主 | 2008-9-20 14:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
 采用485通讯,串口初始化如下,发送数据在串口调试助手中收不到数据,请问串口初始化哪里有问题?
#define UART0_Rx_Pin 0x0100
#define UART0_Tx_Pin 0x0200
#define UART0_RE_DE_Pin 0x0040

 UART_DeInit(UART0);
   /*Enable Clock for UART0*/
  CFG_PeripheralClockConfig(CFG_CLK_UART0 , ENABLE);
/*Enable Clock for GPIO6*/
  CFG_PeripheralClockConfig(CFG_CLK_GPIO6 , ENABLE); 
   /* CMU Initialization */

  /*Configure CMU and switch to the external 4MHz Quartz*/
  CMU_InitStruct.CMU_CKSEL0 = CMU_CKSEL0_CKOSC;
  CMU_Init (&CMU_InitStruct);


/* Configure the GPIO pins as alternate function push pull*/
  GPIO6_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO6_InitStruct.GPIO_Pins = UART0_Tx_Pin ;
  GPIO_Init (GPIO6, &GPIO6_InitStruct);
  
  GPIO6_InitStruct.GPIO_Mode = GPIO_Mode_IN_TRI_TTL;
  GPIO6_InitStruct.GPIO_Pins = UART0_Rx_Pin;
  GPIO_Init (GPIO6, &GPIO6_InitStruct);

  GPIO6_InitStruct.GPIO_Mode = GPIO_Mode_OUT_PP;
  GPIO6_InitStruct.GPIO_Pins = UART0_RE_DE_Pin ;
  GPIO_Init (GPIO6, &GPIO6_InitStruct);
  
  /* UART Configuration */
  UART_StructInit(&UART_InitStruct);             /*Initialize Structure with default values*/
  UART_InitStruct.UART_BaudRate  = 9600;         /* Baud rate value */
  UART_InitStruct.UART_Mode = UART_Mode_8D;   /*Set the UARTx Mode  8 bit Data + Parity */
  UART_InitStruct.UART_Loop_Standard = UART_Standard; /*Disable LoopBack*/
  UART_InitStruct.UART_StopBits = UART_StopBits_1; /* STOP bits number */
  //UART_InitStruct.UART_Parity = UART_Parity_Even;    /* Parity bit */ 
  UART_InitStruct.UART_Rx = UART_Rx_Enable;
  UART_Cmd(UART0, ENABLE);
  UART_Init(UART0, &UART_InitStruct);   /*Configure Uart0*/
  // UART_FifoReset(UART0,UART_TxFIFO);
  //UART_FifoReset(UART0,UART_RxFIFO);

UART0_RE_DE_High();         //485发送使能
UART_ByteSend(UART0, 0xaa); //发送数据
沙发
香水城| | 2008-9-20 18:22 | 只看该作者

用示波器看看

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

14

主题

16

帖子

0

粉丝