Using GPS Module on USART2

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
simsto
Flowcode V4 User
Posts: 19
Joined: Fri Jul 08, 2011 4:20 pm
Has thanked: 3 times

Using GPS Module on USART2

Post by simsto »

Hello,

I would like to use my EB065 on an USART2. I've set MX_GPS_UART=2 in the code customization area. But it doesn't work. On USART1, the program works as expected. I am using a PIC18F45k22.
Is there an issue with the PPS-Signal? The jumper settings are C&1.

Best regards
Simon

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: Using GPS Module on USART2

Post by Benj »

Hi Simon,

When you change the definition from

Code: Select all

	#define MX_GPS_UART			1		//%e			//UART Control
to

Code: Select all

	#define MX_GPS_UART			2		//%e			//UART Control
it should work to switch the GPS to UART2.

Does the program compile ok when you have done this or are there any error messages?

The Jumper settings of the E-block should be made so that the serial data signals are routed through to the UART2 pins. The EB056 datasheet should help to get the jumpers setup correctly. The PPS signal does not have to be connected and is just made available should anyone want to bring it into their application.

simsto
Flowcode V4 User
Posts: 19
Joined: Fri Jul 08, 2011 4:20 pm
Has thanked: 3 times

Re: Using GPS Module on USART2

Post by simsto »

Hello Benj,

unfortunately it doesn't work. I've attached my flowchart. The RX1/TX1-Pins are RC7/RC6 and RX2/TX2 are at RD7/RD6. Though, I think that I don't have to change my jumper settings.With

Code: Select all

#define MX_GPS_UART			1
it works fine.

The code does compile without errors.

Edit:
Here is a little snippet from the generated asm-file:
MOVWF gbl_txsta2
MOVLW 0x19
MOVWF gbl_spbrg2
CLRF gbl_rcsta2
BSF gbl_rcsta2,7
BCF gbl_intcon,7
CALL FCD_GPS0_G_0003E
CALL FCD_GPS0_G_0003E
BSF gbl_txsta,5

Everything points to rcsta2 and txsta2 but not the last row. It is the txen-Bit of USART 1 and I think it should be: bsf gbl_txsta2,5.
Could this be the error and how can a solve it?

Best regards
Simon
Attachments
Flowcode45kGPS2.fcf
(13.17 KiB) Downloaded 340 times

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: Using GPS Module on USART2

Post by Benj »

Hi Simon,

That's great thanks you pointed me straight to the bug.

Here is the updated component C file for v4 which should hopefully now work correctly for you on UART2.
PIC_GPS.c
(28.79 KiB) Downloaded 378 times
Simply place the file into your Flowcode v4/Components directory before starting Flowcode. You may also have to revert the code back to default to allow the changes to be brought in before switching the UART channel definition back to 2.

simsto
Flowcode V4 User
Posts: 19
Joined: Fri Jul 08, 2011 4:20 pm
Has thanked: 3 times

Re: Using GPS Module on USART2

Post by simsto »

Hi Benj,

I like diving into assembly code. :wink:

Unfortunately it doesn't work.

But I've found the following things:

pie4 has to be changed to pie 3
pir4 has to be changed to pir3

Now it works as expected. Hopefully these changes match the other chips with two USART.
I've attached my new c-file:
PIC_GPS.c
(28.81 KiB) Downloaded 344 times
Thank you very much. Now I am going to solve my other prob :D

Best regards
Simon

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: Using GPS Module on USART2

Post by Benj »

That's great thanks for letting me know and glad its working correctly for you now.

Post Reply