dspic24 and RS232 pinout cfg
Moderator: Benj
dspic24 and RS232 pinout cfg
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.
- 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
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.
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.
Other components such as SPI and PWM can also be remapped on certain devices using the same technique.
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
Code: Select all
#if (%m_UART == 1)
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel