Using 2 UART

Post Reply
Stefano
Posts: 5
Joined: Wed Jun 11, 2008 11:35 am

Using 2 UART

Post by Stefano » Wed Jun 11, 2008 1:26 pm

Hi, I need to use two UARTs to communicate with the serial port of a pc and with the serial port of a DC motor controller. For this purpose I'm using a dsPIC30F3011 which has one UART1, one UART1 Alternative and one UART2. Unfortunately I'm having this problems:

1) In the dsPIC toolbox the dsPIC30f3011 has only one UART1 (and one UART1 Alternative), I think that this is a bug. To enable also the UART2 I have modified the property “nuart” in the item number 15 of the file "dspicliste.mat" substituting the existing value with the new value [1 2]. In this way I can select UART1 and UART2 in the dsPICtoolbox... is it correct?

2) everything works fine if I use only one UART (1 or 2), but if I try to use two UARTs, using two "UART configuration" blocks, the compile process generates this error
<<
dsPIC_UART2_Interrupt.c: In function '_U2TXInterrupt':
dsPIC_UART2_Interrupt.c:19: warning: PSV model not specified for '_U2TXInterrupt';
assuming 'auto_psv' this may affect latency
dsPIC_UART2_Interrupt.c: In function '_U2RXInterrupt':
dsPIC_UART2_Interrupt.c:31: warning: PSV model not specified for '_U2RXInterrupt';
assuming 'auto_psv' this may affect latency
pic30-gcc -c -mcpu=30f3011 -O3 -fschedule-insns -fschedule-insns2 -O -I. -I..\.. -IC:\PROGRA~1\MATLAB\R2007b/simulink/include -IC:\PROGRA~1\MATLAB\R2007b/extern/include -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/ert -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src/ext_mode/common -Ic:\MyToolbox\blocks\Test_2_RS232_dspic\sources -Ic:\MyToolbox\blocks -IC:\Users\stefano\Desktop\CONTRO~3\example -IC:\PROGRA~1\MATLAB\R2007b\rtw\c\libsrc -I C:\PROGRA~1\MICROC~1\MPLABC~1\include Test_2_RS232.c
Test_2_RS232.c: In function 'Test_2_RS232_step1':
Test_2_RS232.c:111: error: 'RxPtrHaut_Uart1' undeclared (first use in this function)
Test_2_RS232.c:111: error: (Each undeclared identifier is reported only once
Test_2_RS232.c:111: error: for each function it appears in.)
Test_2_RS232.c:111: error: 'RxPtrBas_Uart1' undeclared (first use in this function)
Test_2_RS232.c:112: error: 'RxTab_Uart1' undeclared (first use in this function)
Test_2_RS232.c:113: error: 'Rx_BUFF_SIZE_Uart1' undeclared (first use in this function)
Test_2_RS232.c: In function 'Test_2_RS232_initialize':
Test_2_RS232.c:271: error: 'TxPtrHaut_Uart1' undeclared (first use in this function)
Test_2_RS232.c:272: error: 'TxPtrBas_Uart1' undeclared (first use in this function)
Test_2_RS232.c:273: error: 'RxPtrHaut_Uart1' undeclared (first use in this function)
Test_2_RS232.c:274: error: 'RxPtrBas_Uart1' undeclared (first use in this function)
gmake: *** [Test_2_RS232.o] Error 255
### Real-Time Workshop build procedure for model: 'Test_2_RS232' aborted due to an error.
>>
I get the same error even if I try to use another dsPIC with two UARTS (without modifying the file "dspicliste.mat").

Can you tell me if it is possible to enable two serial communications within the same dsPIC and how to do it?

Tank you

PS: I've attached to this post the file that I'm using to perform the tests...
Attachments
Test_2_RS232.mdl
(32.71 KiB) Downloaded 552 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Using 2 UART

Post by LubinKerhuel » Thu Jun 12, 2008 12:26 am

Hi Stefano,

Thanks for reporting this bug. It should be corrected now.
Please, have a look on the experimental version of the blockset on the Release Note Page (Bottom).

Lubin

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Using 2 UART

Post by LubinKerhuel » Thu Jun 12, 2008 8:56 am

Hi Stefano,
Stefano wrote:the file "dspicliste.mat" substituting the existing value with the new value [1 2]
This solution is correct in this very specific case. However, in most case, it will not work since severals entry have to be coherent so as to generate a correct C code. The entry has been corrected in the last version of the blockset (0.98c).

Stefano
Posts: 5
Joined: Wed Jun 11, 2008 11:35 am

Re: Using 2 UART

Post by Stefano » Thu Jun 12, 2008 10:18 pm

Thanks Lubin for the fast new release… I will try it as soon as I come back to my office…

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests