dspic24 and RS232 pinout cfg

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
regisD
Flowcode V4 User
Posts: 16
Joined: Wed Apr 07, 2010 7:48 am
Location: France, Troyes
Contact:

dspic24 and RS232 pinout cfg

Post by regisD »

hi, with dspic24 it's possible to freealloc the Rx/Tx port, this option is not directly accessable in the software (i think it can be usefull) so if i want modifie it, i must go in the user code (right?), can you give an help file to know what to do in this case? Thanks.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: dspic24 and RS232 pinout cfg

Post by Benj »

Hello,

Yes this is possible.

First of all look at the C code file created by Flowcode. Near the top of the file you will see a set of definitions. You are looking for one of the following.

MX_UART1_PORT_FREEALLOC or MX_UART1_PORT_E16ALLOC

If you see one of these then your UART pins can be remapped.

In Flowcode click on the RS232 component and then select code customization.

Edit the initialisation section of the code and you will find the pin remapping code which should look like this.

Code: Select all

	#ifdef MX_UART1_PORT_FREEALLOC

		#ifdef MX_UART1_ALT
			RPOR0 = (RPOR0 & 0xFF00) | 0x03;	//Assign U1TX - RP0 / PORTB0
		#else
			RPOR3 = (RPOR3 & 0xFF00) | 0x03;	//Assign U1TX - RP6 / PORTB6
		#endif

		RPINR18 = (RPINR18 & 0xFF00) | 0x07;	//Assign U1RX - RP7 / PORTB7

	#endif

	#ifdef MX_UART1_PORT_E16ALLOC

		RPOR8 = (RPOR8 & 0xFF00) | 0x03;		//Assign U1TX - RP16 / PORTC0
		RPINR18 = (RPINR18 & 0xFF00) | 0x11;	//Assign U1RX - RP17 / PORTC1

	#endif
Depending on your chip type edit the code in the appropriate define and this will change the remapping for your device. Ensure to select the right UART for your application.

Code: Select all

#if (%m_UART == 1)
Other components such as SPI and PWM can also be remapped on certain devices using the same technique.

regisD
Flowcode V4 User
Posts: 16
Joined: Wed Apr 07, 2010 7:48 am
Location: France, Troyes
Contact:

Re: dspic24 and RS232 pinout cfg

Post by regisD »

thanks a lot for your help

Post Reply