Page 1 of 1

UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 10:13 am
by QMESAR
Hi All,
I have configured the UART in the attached project @115200 baud rate however the Rx interrupt is never triggered.
I then just for testing write a char in the main loop however there is no activity on the UART Tx pin.
I have verified that there is activity on the RX pin from my PC data that I send to the PIC (the interrupt does not fire) it seems the UART is totally not working.

Please help to solve this issue :D
FC7.rar
(67.02 KiB) Downloaded 309 times

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 10:48 am
by LeighM
Thanks for the info.
I'll have a quick look and see if I can see anything, but my PIC32 knowledge in next to zero :D

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 11:04 am
by QMESAR
LeighM wrote:Thanks for the info.
I'll have a quick look and see if I can see anything, but my PIC32 knowledge in next to zero :D
You like the ARM controllers to much :D :D
Thanks Leigh appreciate this may be it me doing something wrong :oops:

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 11:09 am
by LeighM
Indeed I do :lol:

Could you try moving the InitMCU() to before the Interrupt Enables?
I think the UART init is turning the interrupt back off.

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 1:31 pm
by QMESAR
I think the UART init is turning the interrupt back off.
Leigh I will do this later when I am back at my lab however this could be and would explain why the RX interrupt is not working but shouldn't the TX still work ? :?

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 2:14 pm
by QMESAR
Hi Leigh

The move of the initMCU() function indeed help to keep the RX interrupt enabled however I see the same problem as Zane here http://www.matrixtsl.com/mmforums/viewt ... 70&t=18939
Once the RX Interrupt fires the first time the main loop is not executed and even the Timer1 interrupt is not executed as my Led toggle in the Timer1 interrupt moves to about 300mSec end longer (my impression is that the code does not return from the Interrupt )
I also doubt that the Tx function is working
if you need scope traces let me know and I will make them

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 2:15 pm
by LeighM
Ooops, sorry, I only replied to your first point, missed the second, just like my bank manager :lol:

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 2:23 pm
by LeighM
Right, and thanks for the reminder about the other post, yes looks like they are connected

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 3:00 pm
by LeighM
Could you please try with the attached FCD?
Thanks,
Leigh
32MX534F064H.fcdx
(42.76 KiB) Downloaded 285 times

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 4:05 pm
by QMESAR
Leigh

Thank for the file unfortunately with me the same symptoms no TX and also the T1 interrupt is delayed to the RX interrupt time

Thanks for your efforts :D

Re: UART PIC32MX534F064H No RX or TX

Posted: Fri Jun 02, 2017 4:12 pm
by LeighM
OK, thanks for trying it. Maybe I need to now concentrate on the Tx side, next week :wink:

Re: UART PIC32MX534F064H No RX or TX

Posted: Tue Jun 13, 2017 10:57 am
by Benj
Hello Peter,

I've applied Leigh's fix to all the PIC32 devices and hopefully this will help the situation.
PIC32.zip
(1.31 MiB) Downloaded 295 times
There is also a new CAL UART file here for the PIC32 which may also help.
http://www.matrixtsl.com/mmforums/viewt ... 930#p82082

Let me know how you get on and I'll have a quick play with the PIC32 devices I have here.

Re: UART PIC32MX534F064H No RX or TX

Posted: Tue Jun 13, 2017 4:31 pm
by QMESAR
Hi Ben
Thank you very much,I am out of my lab this week, I will try it next week and let you know how it went.
Have good one

Re: UART PIC32MX534F064H No RX or TX

Posted: Sun Jun 18, 2017 5:13 pm
by QMESAR
Hi Ben.
I have tried the new files and the following is happening

(1) I have a LED blinking in the T1 interrupt which run exactly 1 sec
(2) I then write 2 chars from the UART no transmission at all no activity on the TX pin
(3) I then activate the UART RX interrupt and sent to the PIC32 2 chars result the moment that the UART Rx interrupt fires the T1 interrupt time change from 1sec to about 4 seconds and I also see no data in the RX buffer

just thought I let you know :D

Re: UART PIC32MX534F064H No RX or TX

Posted: Mon Jun 19, 2017 10:06 am
by Benj
Hello Peter,

Would you mind posting your project file and I will investigate the issue for you. Hopefully something simple.

I'm currently re-looking at the project you posted above.

Re: UART PIC32MX534F064H No RX or TX

Posted: Mon Jun 19, 2017 10:50 am
by Benj
It may also be worth testing just the UART functionality on this device without interrupts. It sounds to me like it's the UART that's having problems and not necessarily the associated interrupts.

Looking at the definition file there is only 5 UARTs defined but the datasheet is showing 6. Hmm.

Re: UART PIC32MX534F064H No RX or TX

Posted: Mon Jun 19, 2017 11:29 am
by QMESAR
Hi Ben,

I will post the file I am just today at a customer location will probably be tomorrow or Wednesday,

Just as info there is a problem with the PIC32 interrupts ,I have had this issue in a normal C file project(MPLAB) and the work around is by enabling the interrupts every time in the interrupt with the highest priority with an assembly instruction
asm EI as for some reason the interrupts get disabled in the interrupt with the highest priority
for example if UART Interrupt is priority 7 and T1 is priority 6 then the UART the EI bit get cleared every time UART interrupt fires by enabling the Interrupts again in the ISR keeps it going and vise versa also will happen meaning if T1 is priority 7 and UART priority 6 the the Interrupts get disabled when T1 fires :D :D I dont want to point you in a wrong direction however it worth while to investigate this in FC

Question how is the priorities set in FC as I did not see any setting for the priorities ? or am I missing something ?

I also did try the UART just by Transmitting 2 chars with out interrupts and I have no activity on the PIC32 TX pin

Ben this is not serious don't loos to musch time on this as if I am the only one suffering with a UART problem

Re: UART PIC32MX534F064H No RX or TX

Posted: Mon Jun 19, 2017 11:33 am
by Benj
A number of this device family had UART definition issues,

The device you're using is missing UART channel 6 and some other devices had a duplicated channel 5?

Here is the current fixed definition file, but this doesn't explain why you're having problems with channel 2. Can you try transmitting from the various UART channels without interrupts and see if any of them are working.
32MX534F064H.fcdx
(42.85 KiB) Downloaded 240 times
I'm going to have a look at the CAL code now and see if I can spot anything incorrect or inconsistent for this family.

Re: UART PIC32MX534F064H No RX or TX

Posted: Mon Jun 19, 2017 11:36 am
by Benj
Looking at the definition file both timer and UARTs should have an interrupt priority of 1. I'm not aware of any problems here with priority but I will investigate.

It might also be nice to have a configuration option to allow the priority to be set which should be fairly simple.

For now let's focus on the UART not working.

Re: UART PIC32MX534F064H No RX or TX

Posted: Mon Jun 19, 2017 12:04 pm
by Benj
I've had another look through the CAL file and added the high speed / low speed baud rate detection that is in the other families.

This should hopefully make things slightly more reliable with slower baud rates combined with fast clock speeds but probably won't effect the faster baud rates.

Have a go with this latest version of the CAL file.
PIC32BIT_CAL_UART.c
(24.54 KiB) Downloaded 243 times
One thing I have noticed is that the UART enable bit is called "UARTEN" whereas the bit in the datasheet for this device is "ON". I've looked at the compiler definitions and it looks like both UARTEN and ON are valid. but this could be something to try.

So if your still getting no joy with any UART at various BAUD rates then try adding this code to a C icon after initialising the UART. Replace U1 with the number of your UART peripheral, e.g. U2 for UART channel 2.

Code: Select all

U1MODEbits.ON = 1;         				// Switch on serial interface

Re: UART PIC32MX534F064H No RX or TX

Posted: Mon Jun 19, 2017 12:18 pm
by Benj
One last thing you could try is to add an external or internal pull up resistor to the UART receive pin, Just to be sure that the chip isn't doing something "clever" like recognising a break and disabling the UART for you.

Re: UART PIC32MX534F064H No RX or TX

Posted: Mon Jun 19, 2017 4:19 pm
by Benj
As a quick test I've added priority options to all the interrupts in this definition file. They all should appear now in the interrupt enable properties.

I've had to get rid of the sub-priority option from the timer interrupts as it looks like Flowcode currently has a hard limit of 4 interrupt options. With the fifth option in place Flowcode currently crashes when loading the project. These timer sub priorities will default to 0 (Lowest). If it's needed then you can always add a C icon to set the sub priority after enabling the interrupt. Not ideal but will work around the problem for now.
32MX534F064H.fcdx
(57.14 KiB) Downloaded 207 times
I've put in a request for the limit to be increased to 5 or 6 but not sure if this will happen now for v7 as it might have knock on consequences.

If you have a go then let me know how you get on. If it looks good then I'll roll this out to the other PIC32 devices, and maybe other devices with interrupt priority control registers.

Re: UART PIC32MX534F064H No RX or TX

Posted: Mon Jun 19, 2017 5:43 pm
by QMESAR
Ben

Thank you very much I will give this all ago and let you know thanks a million for your efforts I appreciate this :D
Have good evening.

Re: UART PIC32MX534F064H No RX or TX

Posted: Wed Jun 21, 2017 7:04 am
by QMESAR
If you have a go then let me know how you get on. If it looks good then I'll roll this out to the other PIC32 devices, and maybe other devices with interrupt priority control registers.
Hello Ben.

I would not recommend doing this now ,I had a change last night to run the new files and I am sad to say not very successful.
(1) Attached is a simple project which Runs T1 Interrupt ,The interrupt only work when the priority is set at Lowest(1) if I use any other priority above 1 - 7 the interrupt does not fire at all( left the sub priority at 0
(2) I then removed the T1 interrupt and Used an UART2RX interrupt The UART is not responding at all ,No TX and NO RX polled or interrupt driven (Unfortunate on this board I can not try another UART port as the mcu is in a custom PCB which all the other pins are wired to some critical stuff.

My conclusion
The UART 2 is not reponding at all (regardles interrupts or polling)
The interrupt priorities is not working as we expect.

Please do not loose time on this issue with me I have to move on I will use the MCC tool set to complete this task and when I have time I will setup a test system to test these issues(specially if the other UART's are working)
I am under pressure to deliver this to my customer ,I have no choice, I have to use MPLAB as you were away and Leigh tried to help and in between is at least 3 weeks :D I am sorry about this but my customer is getting nervous and a bit aggressive with me :oops:

Thank again for your hard work I appreciate all very much