Serialport / GPIO pins

Aug 9, 2012 at 6:08 PM
Edited Aug 9, 2012 at 6:14 PM

How do you access all the GPIO pins of the STM32F4;

I tried to use the Mountaineer pinout from the mountaineer API reference because it also has an STM32F407 (http://u.jimdo.com/www43/p/se3c6ab1e715754e9/download/m78e022258ddd5cc6/1340007373/Mountaineer.Netmf.Hardware.pdf?px-hash=2a9d1410a596fc3685513bae7748d64d5ef4d635&px-time=1344534797) but it does not work , I get a first change exception when I try to write to the led:

I declared the led like that:

public const Cpu.Pin LedGreen = (Cpu.Pin)75;

 

Is there any VS template with the correct pin declerations (PD15, PH1, etc);

Where can I find a pin assignment  map;

Aug 12, 2012 at 1:40 AM
Edited Aug 17, 2012 at 6:27 AM

I found it, it was right in front of me!

MicroFrameworkPK_v4_2\DeviceCode\Targets\Native\STM32F4\ManagedCode\Hardware\CPU.cs

 

Aug 12, 2012 at 5:18 PM

I'm still missing the assignment for the serial port pins.

 

I used GetSerial pins

STM32F4HardwareProvider.HwProvider.GetSerialPins(SerialPorts.COM1, out rx, out tx, out c, out d);
            Debug.Print(rx.ToString() + " " + tx.ToString() + " " + c.ToString() + " " + d.ToString());
            STM32F4HardwareProvider.HwProvider.GetSerialPins(SerialPorts.COM2, out rx, out tx, out c, out d);
            Debug.Print(rx.ToString() + " " + tx.ToString() + " " + c.ToString() + " " + d.ToString());
            STM32F4HardwareProvider.HwProvider.GetSerialPins(SerialPorts.COM3, out rx, out tx, out c, out d);
            Debug.Print(rx.ToString() + " " + tx.ToString() + " " + c.ToString() + " " + d.ToString());
            STM32F4HardwareProvider.HwProvider.GetSerialPins(SerialPorts.COM4, out rx, out tx, out c, out d);
            Debug.Print(rx.ToString() + " " + tx.ToString() + " " + c.ToString() + " " + d.ToString());
            STM32F4HardwareProvider.HwProvider.GetSerialPins(SerialPorts.COM5, out rx, out tx, out c, out d);
            Debug.Print(rx.ToString() + " " + tx.ToString() + " " + c.ToString() + " " + d.ToString());
            STM32F4HardwareProvider.HwProvider.GetSerialPins(SerialPorts.COM6, out rx, out tx, out c, out d);
            Debug.Print(rx.ToString() + " " + tx.ToString() + " " + c.ToString() + " " + d.ToString());

 

I got the following results:

10 9 11 12
3 2 51 1
57 56 59 60
43 42 -1 -1
50 44 -1 -1
39 38 -1 -1

 

The board pins are like PA1, PD5, etc.

I tried to use the STM32 discovery board manual but I could not find out the correct pinout. For example , the manual says that pin 50 is GND

Coordinator
Aug 14, 2012 at 9:01 AM
sdim wrote:

 there any VS template with the correct pin declerations (PD15, PH1, etc);

Note that pins PAxx go from 0 to 15, PBxx go from 16 to 31, PCxx go from 32 to 47, and so on. This numbering is different from the physical pin numbers that you can also find in the data sheets.

Coordinator
Aug 14, 2012 at 9:03 AM
sdim wrote:

I'm still missing the assignment for the serial port pins.

COM<n> is mapped to the microcontroller's USART<n>.

Aug 17, 2012 at 6:28 AM

I have tried to use a few COM pors, as you described, but it did not work.

Maby the device was not compatible with USART, I will try one of the UART ports.

Oct 24, 2012 at 8:41 AM
sdim wrote:

I have tried to use a few COM pors, as you described, but it did not work.

Maby the device was not compatible with USART, I will try one of the UART ports.


Be careful on 2 important things !

1. The UART is TTL, when RS232 will be -12/+12V signal, so if you want for example to dialog between the Discovery and a PC, you'll have to add a TTL-RS232 converter (based on MAX232) to comply the signal conversion,

2. The HardwareProvider.cs and CPU.cs classes are the best way to use to avoid mismatching the PIN assignements and numbering problems ! You will find them in the NETM PK !

Nov 7, 2012 at 6:50 AM
sdim wrote:

I have tried to use a few COM pors, as you described, but it did not work.

Maby the device was not compatible with USART, I will try one of the UART ports.

COM1: rx=PA10 tx=PA9 cts=PA11 rts=PA12 1281-5250000bps and non-std speeds
COM2: rx=PA3 tx=PA2 cts=PD3 rts=PA1 640-2625000bps and non-std speeds
COM3: rx=PD9 tx=PD8 cts=PD11 rts=PD12 640-2625000bps and non-std speeds
COM4: rx=PC11 tx=PC10 cts=NC rts=NC 640-2625000bps and non-std speeds
COM5: rx=PD2 tx=PC12 cts=NC rts=NC 640-2625000bps and non-std speeds
COM6: rx=PC7 tx=PC6 cts=NC rts=NC 1281-5250000bps and non-std speeds

Here are the COM pin mappings and available speeds.  I tested transmitting from each serial port at 9600bps, and was successful with COM2, COM3, COM4, and COM6, except COM3 rts=PD12 interferes with the green LED on the stm32f-discovery board.  Not sure why COM1 and COM5 didn't work for me.  I'll stick with the even ones COM2, 4, 6 for now.

Nov 7, 2012 at 7:45 AM
davervw wrote:
sdim wrote:

I have tried to use a few COM pors, as you described, but it did not work.

Maby the device was not compatible with USART, I will try one of the UART ports.

 

 

 

 

Here are the COM pin mappings and available speeds.  I tested transmitting from each serial port at 9600bps, and was successful with COM2, COM3, COM4, and COM6, except COM3 rts=PD12 interferes with the green LED on the stm32f-discovery board.  Not sure why COM1 and COM5 didn't work for me.  I'll stick with the even ones COM2, 4, 6 for now.

 

 

 

COM1: rx=PA10 tx=PA9 cts=PA11 rts=PA12 1281-5250000bps and non-std speeds
COM2: rx=PA3 tx=PA2 cts=PD3 rts=PA1 640-2625000bps and non-std speeds
COM3: rx=PD9 tx=PD8 cts=PD11 rts=PD12 640-2625000bps and non-std speeds
COM4: rx=PC11 tx=PC10 cts=NC rts=NC 640-2625000bps and non-std speeds
COM5: rx=PD2 tx=PC12 cts=NC rts=NC 640-2625000bps and non-std speeds
COM6: rx=PC7 tx=PC6 cts=NC rts=NC 1281-5250000bps and non-std speeds


PA9 to PA12 (COM1) are also used for the USB On the Go, which probably explain the problem you encouter !

For the rest, the use of RTS and CTS is not an absolute necessity in all cases, if you can match with half duplex communication....

 

Nov 8, 2012 at 7:50 PM
LouisCPro wrote:

PA9 to PA12 (COM1) are also used for the USB On the Go, which probably explain the problem you encouter ! 

Okay, I see that on the schematic now.  That explains COM1 not working.  COM5 transmission tx=PC12 is working for me now too, not sure why wasn't before. 

LouisCPro wrote:

For the rest, the use of RTS and CTS is not an absolute necessity in all cases, if you can match with half duplex communication....





The following code gets rid of rts for COM3, but only if performed prior to allocating the OutputPort for the green LED.  Timing (order of operation) is important!!!

port = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One); 
port.Handshake = Handshake.None; // turn off CTS/RTS and XON/XOFF
port.Open();