新手入门
- 积分
- 22
- 金钱
- 22
- 注册时间
- 2014-4-7
- 在线时间
- 0 小时
|
发表于 2014-4-29 11:40:08
|
显示全部楼层
我调出来了 ,不过只能在PCLK1设置为36MHz 才有用,我想用8M不成功,正在研究中,谁弄过的给点经验。36MHz的如下:
/****************************************************************
* 名 称:USART3_Configuration(u16 BaudRate) *
* 功 能:配置串口2 *
* 输 入:无 *
* 返回值:无 *
****************************************************************/
void USART3_Configuration(void)
{
/* USART3 configuration -------------------------------------------------------*/
/* USART3 configured as follow:
- Word Length = 9 Bits
- 0.5 Stop Bit
- Even parity
- BaudRate = 12096 baud
- Hardware flow control disabled (RTS and CTS signals)
- Tx and Rx enabled
- USART Clock enabled
- USART CPOL Low
- USART CPHA on first edge
- USART Last Bit Clock Enabled
*/
USART_InitTypeDef USART_InitStructure;
USART_ClockInitTypeDef USART_ClockInitStructure;
// USART3配置
USART_StructInit(&USART_InitStructure); // 把USART_InitStruct中的每一个参数按缺省值填入
/* USART Clock set to 4.5MHz (PCLK1 = 36 MHZ / 8) BaudRate = Fclk/372;*/
USART_SetPrescaler(USART3, 0x04);
/* USART Guard Time set to 2 Bit */
USART_SetGuardTime(USART3, 0x2);
USART_ClockInitStructure.USART_Clock = USART_Clock_Enable;
USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low;
USART_ClockInitStructure.USART_CPHA = USART_CPHA_1Edge;
USART_ClockInitStructure.USART_LastBit = USART_LastBit_Enable;
USART_ClockInit(USART3, &USART_ClockInitStructure);
USART_InitStructure.USART_BaudRate = 12096;
USART_InitStructure.USART_WordLength = USART_WordLength_9b;
USART_InitStructure.USART_StopBits = USART_StopBits_1_5;
USART_InitStructure.USART_Parity = USART_Parity_Even;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(USART3, &USART_InitStructure);
/* Enable the USART3  arity Error Interrupt */
// USART_ITConfig(USART3, USART_IT_PE, ENABLE);
// 允许USART3接收中断
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
/* Enable USART3 */
USART_Cmd(USART3, ENABLE);
/* Enable the NACK Transmission */
USART_SmartCardNACKCmd(USART3, ENABLE);
/* Enable the Smartcard Interface */
USART_SmartCardCmd(USART3, ENABLE);
} |
|