UART PIC32MX534F064H No RX or TX
Moderator: Benj
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
UART PIC32MX534F064H No RX or TX
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
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
- Attachments
-
- 1.JPG
- (54.06 KiB) Not downloaded yet
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
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
I'll have a quick look and see if I can see anything, but my PIC32 knowledge in next to zero
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
You like the ARM controllers to muchLeighM 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
Thanks Leigh appreciate this may be it me doing something wrong
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
Indeed I do
Could you try moving the InitMCU() to before the Interrupt Enables?
I think the UART init is turning the interrupt back off.
Could you try moving the InitMCU() to before the Interrupt Enables?
I think the UART init is turning the interrupt back off.
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
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 ?I think the UART init is turning the interrupt back off.
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
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
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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
Ooops, sorry, I only replied to your first point, missed the second, just like my bank manager
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
Right, and thanks for the reminder about the other post, yes looks like they are connected
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
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
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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
OK, thanks for trying it. Maybe I need to now concentrate on the Tx side, next week
- 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: UART PIC32MX534F064H No RX or TX
Hello Peter,
I've applied Leigh's fix to all the PIC32 devices and hopefully this will help the situation. 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.
I've applied Leigh's fix to all the PIC32 devices and hopefully this will help the situation. 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.
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
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
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
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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
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
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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- 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: UART PIC32MX534F064H No RX or TX
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.
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.
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
- 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: UART PIC32MX534F064H No RX or TX
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.
Looking at the definition file there is only 5 UARTs defined but the datasheet is showing 6. Hmm.
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
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
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 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
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 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
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- 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: UART PIC32MX534F064H No RX or TX
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.
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.
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.
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.
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
- 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: UART PIC32MX534F064H No RX or TX
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.
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.
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
- 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: UART PIC32MX534F064H No RX or TX
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.
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.
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.
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
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
- 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: UART PIC32MX534F064H No RX or TX
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.
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
- 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: UART PIC32MX534F064H No RX or TX
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.
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.
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.
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.
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
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
Ben
Thank you very much I will give this all ago and let you know thanks a million for your efforts I appreciate this
Have good evening.
Thank you very much I will give this all ago and let you know thanks a million for your efforts I appreciate this
Have good evening.
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: UART PIC32MX534F064H No RX or TX
Hello Ben.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.
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 I am sorry about this but my customer is getting nervous and a bit aggressive with me
Thank again for your hard work I appreciate all very much
- Attachments
-
- BlinkLed_interrupt.rar
- (37.11 KiB) Downloaded 211 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR