高级会员

- 积分
- 534
- 金钱
- 534
- 注册时间
- 2013-7-4
- 在线时间
- 13 小时
|
10金钱
很久没有碰32,遇到一个问题,串口3初始化成功,发送显示也没问题(tc flag set之后reset),示波器量引脚却没什么反应 附件是代码
代码如下
#define CHIPID 0x0088
u8 Recevie_seq[16];
u8 Recevie_count=0;
void RN_PIN_Config(void){
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB,GPIO_Pin_5);//en on
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;//
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//????
// GPIO_Init(GPIOC, &GPIO_InitStructure);//
// GPIO_ResetBits(GPIOC, GPIO_Pin_10);//
// Delay_ms(25);//
// GPIO_SetBits(GPIOC, GPIO_Pin_10);//
// Delay_ms(20);//RESET RN
// GPIO_DeInit(GPIOC);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //
GPIO_Init(GPIOC, &GPIO_InitStructure); //
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;//
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//
GPIO_Init(GPIOC, &GPIO_InitStructure);//
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;//
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;//
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//
NVIC_Init(&NVIC_InitStructure);
USART_InitStructure.USART_BaudRate = 4800;//
USART_InitStructure.USART_WordLength = USART_WordLength_9b;//
USART_InitStructure.USART_StopBits = USART_StopBits_1;//
USART_InitStructure.USART_Parity = USART_Parity_Even;//
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //
USART_Init(USART3, &USART_InitStructure); //
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);//
// USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);//
// USART_ITConfig(USART3, USART_IT_TXE, ENABLE);//
USART_Cmd(USART3, ENABLE);
}
void RN_write(u16 command,u16 *Data,u8 Len){
int i;
USART_SendData(USART3,CHIPID);
while(USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET){}
USART_SendData(USART3,command|0x80);
while(USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET){}
for(i=0;i<Len;i++){
USART_SendData(USART3,Data[i]);
while(USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET){}
}
};
void RN_Read(u16 command,u8 Len){
int i;
USART_SendData(USART3,CHIPID);
while(USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET){}
USART_SendData(USART3,command);
while(USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET){}
Recevie_count=0;
while(Recevie_count<Len){}
Recevie_count=0;
};
void RN_Init(void){
RN_PIN_Config();//Init Pin map;
RN_Read(0x7F,3);
}
void USART3_IRQHandler(void)
{
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) //
{
Recevie_seq[Recevie_count] =USART_ReceiveData(USART3); //
if(Recevie_count<16)
Recevie_count++;
else
Recevie_count=0;
USART_ClearFlag(USART3,USART_FLAG_RXNE);
}
}
|
|