2016-02-24 02:12 AM
I have difficulty handling Discover Wi-Fi.
Currently, I am using keil vision and stm32f407 as a host mcu device Also, I am trying to modify the example code but it is not working well.
I need help and advice. In the example, PB6 and PB7 are used to communicate with host mcu.
Unfortunately, I have already assigned these pins to the another function.
So I changed and tried several times such as UART1 to UART2, UART1 to UART3 and UART1 to UART1(PA9,PA10).
Surprisingly, It is only operated in PB6,PB7.... Does anybody know what happen in here and how to change it?
I tried the EWW website and others... it did not work.. I am really looking forward to meeting your answer.
Thanks
2016-02-24 02:30 AM
Electrons only go where the wires are attached.
2016-02-24 06:11 AM
I wired every time when I change the other UART.
For instance, When I use UART2, I connect PA2 and PA3 with the wifi module.But It did not work. Could you give me a help?2016-02-24 08:23 AM
I don't have this board, or the software you are trying to compile and use.
You'll will need to present your problem in a manner that can be reviewed and understood. Showing the code and circuit diagram is more usable than prose describing things.The USART clocks and configuration must be correct. The pin assignments and AF mux settings must be correct.Diagram how you have things connected, and what else is connected to the DISCO.Get a scope and determine what signals you can see, and refine ''not working'' into a more specific description of what is happening, and what is expected. Do this at the pin level, not from a system overview level.2016-02-24 10:36 PM
Firstly, Thanks for reply.
-For the software
I changed below code. Below code is given and I changed USART1 --> USART2
and pin assignment are changed to PA2 as a Tx and PA3 as a RX.
Also UART CLOCK is changed APB2 --> APB1.
-For the hardware
I wired PA2 with SN8200 RX pin and PA3 with SN8200 TXpin
P.S.Because I am out of offices I will scope as your recommendation.Thanks************code******************void SN8200_HAL_Init(uint32_t baudrate){
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable GPIO clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
/* Enable UART clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
/* Connect PXx to USARTx_Tx*/
GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1);
/* Connect PXx to USARTx_Rx*/
GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1);
/* Configure USART Tx as alternate function */
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Configure USART Rx as alternate function */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_Init(GPIOB, &GPIO_InitStructure);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
/* Enable the USART1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* USART configuration */
USART_InitStructure.USART_BaudRate = baudrate;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_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(USART1, &USART_InitStructure);
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
/* Enable USART */
USART_Cmd(USART1, ENABLE);
}
void SN8200_HAL_SendData(unsigned char *buf, int len)
{
int i;
for (i = 0; i < len; i++) {
USART_SendData(USART1, buf[i]);
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
}
}
bool SN8200_HAL_RxBufferEmpty(void)
{
return (RxBufferHead == RxBufferTail);
}
uint8_t SN8200_HAL_ReadByte(void)
{
uint8_t data = 0;
if(RxBufferHead != RxBufferTail) {
data = RxBuffer[RxBufferTail];
RxBufferTail = (RxBufferTail + 1) % RX_BUFFER_SIZE;
}
return data;
}
void USART1_IRQHandler(void)
{
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) {
RxBuffer[RxBufferHead] = USART_ReceiveData(USART1);
RxBufferHead = (RxBufferHead + 1) % RX_BUFFER_SIZE;
}
}
2016-02-26 12:25 AM
@Clive1
Hello,I did what you recommend and I found one problem.A problem is that Tx pin is not changed even if I changed it code well.1. Given example , Tx, Rx are assigned PB6,PB7 respectively.2. I changed it to UART2 and Tx, Rx are assigned PA2,PA3 respectively and wiring is also well.3. I scope PA2 and PA3 then, PA3 state is high butt PA1 is low. and I also scope to UART1 which are PB6 and PB7. PB6 is still high and PB7 is low.Summary: Only UART Tx is not changed...Could you give me advice and share your idea with me?It would be very helpful Thanks2016-02-26 01:50 AM
For changing UART <A> at pins <a1>/<a2> to UART <B> at <b1>/<b2>, check that you:
2016-02-26 03:46 AM
2016-02-27 05:04 AM
Here an example for UART3, that works for me:
/* Initialize the USART3 (CMD_BAUDRATE,8,n,1,none) command interface
* PD8 => usart3.TX
* PD9 => usart3.RX
* these pins are available on the F4 Discovery board
*/
void initUART (void)
{
uint32_t sendBytes;
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
USART_ClockInitTypeDef USART_ClockInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd (RCC_APB1Periph_USART3, ENABLE); // configure clock for USART
RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOD, ENABLE); // configure clock for GPIO
GPIO_PinAFConfig (GPIOD, GPIO_PinSource8, GPIO_AF_USART3); // configure AF
GPIO_PinAFConfig (GPIOD, GPIO_PinSource9, GPIO_AF_USART3);
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = DATA_BAUDRATE;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init (USART3, &USART_InitStructure);
USART_ClockInitStructure.USART_Clock = USART_Clock_Disable;
USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low;
USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge;
USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable;
USART_ClockInit (USART3, &USART_ClockInitStructure);
USART_Cmd (USART3, ENABLE);
/* parametrize USART3-Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init (&NVIC_InitStructure);
/* Interrupt at reception and receive errors */
USART_ITConfig (USART3, USART_IT_RXNE, ENABLE);
USART_ITConfig (USART3, USART_IT_ERR, ENABLE);
}
Of course you don't the error interrupts, if you are not willing to handle them.
As suggested in other threads, connect RX and TX of the UART directly, and check if you receive the characters you transmit.
If that works, your initialization is o.k., and you can go on to check the hardware to your WiFi adapter.
2016-03-01 11:14 PM