cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f4 rs232 IAR IDE

achourwissem
Associate II
Posted on June 02, 2013 at 13:34

hello :)

i had a problem  when i send a character or receive a character , i always get a wrong character like ''-'' or a heart ...

ps: i'm using rs232 -> USB converter

here is my code:

&sharpinclude ''stm32f4xx.h''

void main()

{

 //UART4 initialization

RCC->APB1ENR |= 0x00080000; // Enable clock for UART4

RCC->AHB1ENR |= 0x00000004; // Enable clock for GPIOC

GPIOC->MODER |= 0x00a00000; // PC10, PC11 => AF mode

GPIOC->AFR[1] |= 0x00008800; // select AF8 (UART4,5,6) for PA10, PA11

UART4->BRR = 0x1120; // 9600 baud

UART4->CR1 |= 0x200c; // Enable UART for TX, RX

UART4->CR1 |= 0x0020; // Enable RX interrupt

while(1){

  if (UART4->SR & 0x0080) {

   UART4->DR='a';

   for (int i=0; i<10000000; i++) {};

  }

}

}

please any help! :(

#too-vague
20 REPLIES 20
Posted on June 04, 2013 at 21:24

That does put you in a bit of a pickle.

Also be conscious that the STM32 outputs CMOS levels, not RS232 compatible levels. You want to be using a USB-to-CMOS Serial type device where the STM32 connects directly to a chip from FTDI, Prolific or SiLabs. For RS232 interfacing a MAX3232 type level converter will be required.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
achourwissem
Associate II
Posted on June 05, 2013 at 00:08

but even i'm using usb -> rs232 converter ? because many said to me that i dont need max232 or other to make it works

Posted on June 05, 2013 at 02:09

but even i'm using usb -> rs232 converter ? because many said to me that i dont need max232 or other to make it works

Well let's be careful here, using a USB-to-RS232  *IS* going to require a MAX232/3232 type device. To be avoiding that you need something different. Like this DLP-TXRX type device.

http://www.dlpdesign.com/usb/txrx.shtml

Maybe you can cite specifically what you are attempting to interface with, ideally with a part# and web link.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
achourwissem
Associate II
Posted on June 08, 2013 at 10:49

thank you , i will put an extra effort to resolve this problem then i will feed back my results

achourwissem
Associate II
Posted on June 08, 2013 at 12:07

Clive can u attach your system_stm32f4xx.c file for stm32f4 dsicovery? and thnak you

Posted on June 08, 2013 at 13:10

This is the one in STM32F4-Discovery_FW_V1.1.0\Project\Demonstration\

/public/STe2ecommunities/mcu/Lists/STM32Discovery/Attachments/6370/system_stm32f4xx.c

________________

Attachments :

system_stm32f4xx.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hznd&d=%2Fa%2F0X0000000bPm%2FXiYcXZgm_U2et6i.lOrwQh2MuT2vGiuhzoQztIrwoxs&asPdf=false
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
achourwissem
Associate II
Posted on June 10, 2013 at 22:26

thank you so much , probably i have problem in 3.3 v -> 5v conversion (i use usb cable for rs232) so i have to make a circuit to do that conversion or buy a TI component to do this job

Posted on June 10, 2013 at 22:58

i use usb cable for rs232

Does it have a part number or web site?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
achourwissem
Associate II
Posted on June 11, 2013 at 11:59

it's this reference http://pdf.datasheetcatalog.net/datasheet/maxim/MAX3233E-MAX3235E.pdf

it has an internal capacitors
Posted on June 11, 2013 at 14:35

I was asking about the USB-to-RS232/Serial cable that you are using.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..