سلام
ممکنه در مورد دریافت uart5 راهنمایی بفرمائید
usart 1 , 2, 3 بدون مشکل کار میکنن ولی در uart5 , 4 نمیتونم دریافت رو فعال کنم !!
کد رو اینجا گذاشتم :
void UART5_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_AP B2Periph_GPIOD, ENABLE );
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; //UART5 TX;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //??????;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure); //??C;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //UART5 RX;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //????;
GPIO_Init(GPIOD, &GPIO_InitStructure); //??D;
USART_InitStructure.USART_BaudRate = 9600; //???;
USART_InitStructure.USART_WordLength = USART_WordLength_8b; //???8?;
USART_InitStructure.USART_StopBits = USART_StopBits_1; //???1?;
USART_InitStructure.USART_Parity = USART_Parity_No ; //????;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
//?????;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
//????;
USART_Init(UART5, &USART_InitStructure);//??????;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //?????,4??????,4??????;
NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn; //???;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriori ty = 0; //?????;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //?????;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
USART_ITConfig(UART5, USART_IT_RXNE, ENABLE);
USART_Cmd(UART5, ENABLE); //????;
}
void UART5_Send_Byte(u8 Data) //??????;
{
USART_SendData(UART5,Data);
while( USART_GetFlagStatus(UART5, USART_FLAG_TC) == RESET );
}
void UART5_Send_String(u8 *Data) //?????;
{
while(*Data)
UART5_Send_Byte(*Data++);
}
void UART5_IRQHandler(void) //??????;
{
u8 res;
if(USART_GetITStatus(UART5, USART_IT_RXNE) == SET) //????????;
{
USART_ClearFlag(UART5, USART_IT_RXNE); //?????;
res=USART_ReceiveData(UART5); //????;
UART5_Send_Byte(res); //?????;
}
}
ممکنه در مورد دریافت uart5 راهنمایی بفرمائید
usart 1 , 2, 3 بدون مشکل کار میکنن ولی در uart5 , 4 نمیتونم دریافت رو فعال کنم !!
کد رو اینجا گذاشتم :
void UART5_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_AP B2Periph_GPIOD, ENABLE );
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; //UART5 TX;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //??????;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure); //??C;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //UART5 RX;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //????;
GPIO_Init(GPIOD, &GPIO_InitStructure); //??D;
USART_InitStructure.USART_BaudRate = 9600; //???;
USART_InitStructure.USART_WordLength = USART_WordLength_8b; //???8?;
USART_InitStructure.USART_StopBits = USART_StopBits_1; //???1?;
USART_InitStructure.USART_Parity = USART_Parity_No ; //????;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
//?????;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
//????;
USART_Init(UART5, &USART_InitStructure);//??????;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //?????,4??????,4??????;
NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn; //???;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriori ty = 0; //?????;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //?????;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
USART_ITConfig(UART5, USART_IT_RXNE, ENABLE);
USART_Cmd(UART5, ENABLE); //????;
}
void UART5_Send_Byte(u8 Data) //??????;
{
USART_SendData(UART5,Data);
while( USART_GetFlagStatus(UART5, USART_FLAG_TC) == RESET );
}
void UART5_Send_String(u8 *Data) //?????;
{
while(*Data)
UART5_Send_Byte(*Data++);
}
void UART5_IRQHandler(void) //??????;
{
u8 res;
if(USART_GetITStatus(UART5, USART_IT_RXNE) == SET) //????????;
{
USART_ClearFlag(UART5, USART_IT_RXNE); //?????;
res=USART_ReceiveData(UART5); //????;
UART5_Send_Byte(res); //?????;
}
}