Page 1 of 1
Using GPS Module on USART2
Posted: Fri Feb 17, 2012 9:13 am
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
Re: Using GPS Module on USART2
Posted: Fri Feb 17, 2012 11:58 am
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.
Re: Using GPS Module on USART2
Posted: Sat Feb 18, 2012 9:20 am
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
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
Re: Using GPS Module on USART2
Posted: Mon Feb 20, 2012 11:49 am
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.
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.
Re: Using GPS Module on USART2
Posted: Mon Feb 20, 2012 7:52 pm
by simsto
Hi Benj,
I like diving into assembly code.
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:
Thank you very much. Now I am going to solve my other prob
Best regards
Simon
Re: Using GPS Module on USART2
Posted: Tue Feb 21, 2012 11:52 am
by Benj
That's great thanks for letting me know and glad its working correctly for you now.