2012-10-26 01:57 AM
Hi Guys,
Been trying to get the USART to work for a couple of days now and is time to get some help... This is my code:GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f4xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f4xx.c file
*/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_USART2);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_USART2);
/* GPIO Pins configuration for Alternative Function */
/* for TX Pin */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* for RX Pin */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
//GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
//GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* USARTx configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
*/
USART_InitStructure.USART_BaudRate = 9600;
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(USART2, &USART_InitStructure);
/* Output a message on Hyperterminal using printf function */
//printf(''\n\rUSART Printf Example: retarget the C library printf function to the USART\n\r'');
//RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
//RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
USART_Cmd(USART2,ENABLE);
USART_SendData(USART2, (uint8_t) 0x31);
while (1)
{
}
}
I tried pretty much all the USARTs on the board and I can not send anything.
I looped back the TX & RX pins on my USB to Serial converter and that works fine.
The processor seems to be cycling fine thorough the code when on Debug.
I am complety at a loss why the program will not work, Any assistance would be appreciated.
Best Regards
Luis
2013-04-12 01:16 PM
Without connecting Vcc(pin 2)???
Why would I connect it? Do you plan on running the STM32F4-Discovery from this supply? USBPWR might be more appropriate for that. The data sheet for the part doesn't suggest this is necessary for the configuration used here (USB Powered, 3V3 signalling), please review.2013-04-12 01:30 PM
as usual you are always right ....
thank you Mr clive 1.2013-04-17 09:53 AM
when I connect my MM232R my pc (windows 7) I can t find any new hardware detected to install the driver!!!!
2013-04-17 10:10 AM
Does it appear in Device Manager under Ports (COM & LPT)?
Does it make the ding-dong noise in Windows when you plug it in?2013-04-17 11:46 AM
no...as if I have nothing connected.
2013-04-17 12:09 PM
i will try with an other PC....if i find it in Port(com LPT) what can i do to install my mm232r??,
2013-04-17 12:20 PM
I guess you can re-read the manual and see if I missed something. I'm not a user of this device.
You could stick a multi-meter between USBPWR and GND and confirm it's powered. I'm using other, simpler, USB-to-Serial adapters.2013-04-17 02:03 PM
ok....thank you.
2013-04-17 03:22 PM
Some hubs and host controllers appear to be extremely sensitive to noise. A glitch on the USB lines can causes the device to hang. This problem can be fixed by adding two 47pF capacitors to ground on the USB DP and DM lines. These should be located between the 27Ohm series resistors and the hub.
i find this in but how can i connect the capacitor to the usb DM and DP lines of the PC.??2013-04-17 05:50 PM
Solder them on the back of the connectors, or splice into the cable?
Some how I doubt this is your issue, double check the connections on your MMR board, get a meter and track down what is, and what is not working. The connection of USBPWR and VCC50 being the most critical. Use shorter cables, and don't use a hub, if you think that is a reasonable test to eliminate those as an issue. The capacitors seem like a straw clutching exercise, more targeted at people using the FTDI chips on there own boards, not on a module designed to work out of the box.