Continuing pic32mx270f256b timing issues

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
Zane
Flowcode v5 User
Posts: 199
Joined: Thu Sep 10, 2009 10:57 pm
Location: New Zealand
Has thanked: 93 times
Been thanked: 76 times
Contact:

Continuing pic32mx270f256b timing issues

Post by Zane »

Hi Ben,
Also here is a new definition file you can try to see if this improves the 2X delay problem.

Simply copy the file to your "Flowcode 7/FCD/PIC32/" folder and restart Flowcode.

Let us know how you get on
I have tried installing the new FCD file in the specified directory however this has had no effect. When running a simple loop toggling an led on and off every 500mS the led toggles every second instead.

Thanks

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by QMESAR »

Hi

Just a question are you using a delay component for the 500mSec,

If you do I will not be surprised when the speed is 50% slower,
I have been telling the guys this since the release of PIC32 in Flowcode with a PIC32MX250 some how nobody believes me :D

Here is some info what we did and did not do

http://www.matrixtsl.com/mmforums/viewt ... 63&t=18134

Set up an Interrupt and toggle your led in the Time interrupt and I will bet your time will be correct this is my experienced with FC7 and PIC32MX250/270 family :D

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: Continuing pic32mx270f256b timing issues

Post by Benj »

Hello,

I don't have many PIC32 devices to hand at the minute to help troubleshoot this timing problem.

Please can you try this updated CAL file to see if it helps with the problem. The file lives in the "Flowcode 7/CAL/PIC32BIT" folder.
PIC32BIT_CAL_Delay.c
(4.19 KiB) Downloaded 251 times
Let me know how you get on.

Zane
Flowcode v5 User
Posts: 199
Joined: Thu Sep 10, 2009 10:57 pm
Location: New Zealand
Has thanked: 93 times
Been thanked: 76 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by Zane »

Hi Ben,

I have tried the latest ".C" file and for a 500mS delay it now gives a 250mS delay instead.

Thanks

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by QMESAR »

Hi All

I am trying to test the timings I will post my results once done

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: Continuing pic32mx270f256b timing issues

Post by Benj »

Hello,
I have tried the latest ".C" file and for a 500mS delay it now gives a 250mS delay instead.
Thanks for letting me know, seems we went a bit too far. Hopefully this will fix the delays problem now.
PIC32BIT_CAL_Delay.c
(4.19 KiB) Downloaded 258 times
Also here is a new definition file you can try which hopefully help to correct the timer problem. Maybe test both Timer 1, 2 and 3, hopefully one of them should be correct as they each have different settings.

T1 = CLK / 1
T2 = CLK / 2
T3 = CLK / 4
32MX250F128B.fcdx
(39.08 KiB) Downloaded 237 times
Let me know how you get on.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by QMESAR »

My tests
(1) I am running the original cal files as installed by FC

Using XT 20MHz no PLL
It seems the clock speed is incorrect ,as I set the T1 Interrupt to tigger at 19.073 Hz which 52mSEc if the led toggels 1 time high and 1 time low to give on cycle the time should be 52mSec *2 = 104 mSec
I see exactly the that the mcu is running twice as fast Please correct me if I am wrongs Ben ,
this as a starting point to try and track the problem ,
In my opinion as long as the clock does not run at the speed we think it should run all other things will not work correctly
Please inform me Ben if you agree with my timing measurement and then we should we start to analyse the problem
:D
Attachments
1.JPG
1.JPG (12.7 KiB) Viewed 10903 times
2.JPG
2.JPG (34.66 KiB) Viewed 10903 times
3.JPG
3.JPG (45.45 KiB) Viewed 10903 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: Continuing pic32mx270f256b timing issues

Post by Benj »

Hi Peter,

Right first of all I would run a standard 1 second flasher program using delays and see what this is doing. Are the delays correct? If they are then great, if not then try the new CAL file and this should solve the issue. Let me know what works for you.

Next try the updated definition file and try timers 1, 2 and 3. One of these should now be right but I am unsure which one.

I didn't have much of a hand in the PIC32 development and don't have many test boards other than the chipkit boards so it's hard for me to test here currently.

Let me know how you get on.

Zane
Flowcode v5 User
Posts: 199
Joined: Thu Sep 10, 2009 10:57 pm
Location: New Zealand
Has thanked: 93 times
Been thanked: 76 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by Zane »

Hi Ben and Peter,

I have tried the new cal file and the timing is correct using this.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by QMESAR »

Zane wrote:Hi Ben and Peter,

I have tried the new cal file and the timing is correct using this.
Can you please post your Flowchart that you say are working as I see still a huge difference in timing

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by QMESAR »

Hi Ben

Ok Now I have good timing on the Delay and with the timer interrupts (with the new files)and I see no difference between T1 ,2 or 3 they give the same results
however to achieve this result I have to set the Peripheral clock divisor to 2 and I am not sure that this is correct however for the moment I will say it working and read a the Oscillator manual
to make sure that if we start to use CAN and other peripherals that we do not run in problems again .I am concerned how this will effect the USB module so by the way what happened with the USB support on PIC32
as you guys mentioned a few month ago you are working on it :D
Attachments
2.JPG
2.JPG (48.31 KiB) Viewed 10899 times

Zane
Flowcode v5 User
Posts: 199
Joined: Thu Sep 10, 2009 10:57 pm
Location: New Zealand
Has thanked: 93 times
Been thanked: 76 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by Zane »

QMESAR wrote:Hi Ben

Ok Now I have good timing on the Delay and with the timer interrupts (with the new files)and I see no difference between T1 ,2 or 3 they give the same results
however to achieve this result I have to set the Peripheral clock divisor to 2 and I am not sure that this is correct however for the moment I will say it working and read a the Oscillator manual
to make sure that if we start to use CAN and other peripherals that we do not run in problems again .I am concerned how this will effect the USB module so by the way what happened with the USB support on PIC32
as you guys mentioned a few month ago you are working on it :D
I have found that using the UART and having the baud rate set to 9600 the peripheral clock needed to be set to /4 to achieve that. This was mentioned in this posthttp://www.matrixtsl.com/mmforums/viewt ... 63&t=18635

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by QMESAR »

Hi Ben and Zane.

I understand what you are saying however I base my concern on the following
(1) Using the same clock speed settings in MPLAB or in MIKROC PIC32 Compilers and having a Peripheral clock divider of 1 the timing on all is correct(Why do we have to scale the peripheral clock in FC ?)
(2) in my case with 20MHz and a divisor of 2 means my peripherals are running at 10 Mhz now if I for example configure the UART or CAN what Clock speed does FC take to calculate the baudrate as the speed I am telling FC the micro is running at is 20MHZ (see my confusion)

If you guys can help me understand this I will be very happy as I have done a few PIC32 Projects in the last 1-2 years with other tools, how FC is handling the settings and what I am use to in the other tools confuses me ,I would have loved to use FC for these projects as the ICD is not functioning as expected in FC on PIC32 at the moment I did not take the risk.

Zane
Flowcode v5 User
Posts: 199
Joined: Thu Sep 10, 2009 10:57 pm
Location: New Zealand
Has thanked: 93 times
Been thanked: 76 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by Zane »

Hi Peter,

It is my understanding too that with the peripheral clock divisor set to 1 that you should get a baud rate that you select. To have to start manipulating it to get a given baud rate would start getting messy. Then it would also start affecting other peripherals too.

Zane
Flowcode v5 User
Posts: 199
Joined: Thu Sep 10, 2009 10:57 pm
Location: New Zealand
Has thanked: 93 times
Been thanked: 76 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by Zane »

Hi Ben and Qmesar

I have been looking into this timing issue further. I have a program that flashes an led on and off every second driven from a timer interrupt and its clock source is the peripheral clock. The peripheral clock divisor is set to 1. That works as expected.
In the main loop there is a string being sent out from the UART every second. The one second delay is generated from a delay icon. This also works fine sending out the string every second. However the baud rate is set to 9600 but the data is being sent out at 38400. To get it to go out at 9600 i would have to set the peripheral clock divisor to 4. In doing this that would upset the timed interrupt.
Looking at the updated ".FCD" file i have for the PIC32mx270f256 chip, its master divider is set to one where every other 32 bit chip appears to have its master divider set to two. Would that mean that now all the other 32 bit pics will have timing issues? Could the FCD file for the PIC32mx270f256 have its master divider put back to two and the timing issues being corrected in the " *.C" files?
To fix the issue with the delay the "PIC32BIT_CAL_Delay.C" file was altered. Would the "PIC32BIT_CAL_UART.C" need altering to fix the baud rate issues? What about the rest of the files in this directory, would they need altering too to fix any potential timing issues with other functions too?
My understanding of the finer workings of flowcode is virtually non existent but having a look at the above files wondered if that was where the mods were needed? I hope this is of some help to fixing this problem.

Thanks

Zane
Attachments
Flowcode4.fcfx
(9.22 KiB) Downloaded 170 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by QMESAR »

Zane

Thank you for your feedback,
In my experience with the other tools is that the peripheral clock is set to divider 1 and as you have seen is that the clock speed is correct as the peripheral clock matches the input clock ,now it is the situation that to calculate the buad rate for example the UART you take now the peripheral clock speed and calculate that for the value that should go into UART baudrate register .for me when Peripheral clock match input clock value and the UART baud is incorrect then FC uses the wrong clock speed or calculate it incorrectly ,I have worked with a few PIC32 and I have not seen this issue on them at all I have used PIC32MX460,534 and 795 in another tool chain ,I will try to run your FC chart with me some time this week as tomorrow and Tuesday I will be at the hospital.(will run your FC chart on my hardware and analyse what you have seen :D ) With me on my hardware I have not seen the interrupt run correctly unless I set the Peripheral divider to 2, strange this here happening I am lost :oops: Unfortunately I do not have PIC32MX270F256B device only PIC32MX250F128B I will order one tomorrow.

You can test my theory by setting the clock speed to 50% in the project settings then your baud should be correct and your interrupt might go off again
In my opinion and experince so far with PIC32 is that this timing issue is not a PIC32 problem more a misunderstanding or something small incorrect in FC that is causing this and with your help mine and Ben sure we will solve it :D

We have the hardware and Ben the knowledge :D
Attachments
1.JPG
1.JPG (33.19 KiB) Viewed 10856 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by QMESAR »

Hi All

Just for information
Here are a screen shot of the settings on another tool as you see I set the Peripheral clock to 1 divide and set the Clock speed to 20Mhz as that is the clock (XT I am using to be the same as zane) with out PLL
then I blink a led at 20mSec and write out a string on the UART both are corret the UART Baudrate and the Led flash timing,
What this shows to me is the following
(1) The OSC number fits the peripheral clock and the speed it is clear that if you want other speeds that you can apply the Peripheral clock divider however then you also have to set the XT clock speed accordingly example if we now set a PB/divide of 2 then we need to set the clock speed to 10MHz as the peripherals are driven by the Peripheral clock ,but in FC we have a XT speed setting of 20 Mhz and set a divider of 2(10Mhz ) that the interrupt timing and delay are correct but clearly the peripheral modules such as UART CAN etc will have wrong baud rates ,
@Ben Can you suggest some place to look or what to try next in FC ?
Attachments
1.JPG
1.JPG (80.09 KiB) Viewed 10854 times
3.JPG
3.JPG (35.05 KiB) Viewed 10854 times

Zane
Flowcode v5 User
Posts: 199
Joined: Thu Sep 10, 2009 10:57 pm
Location: New Zealand
Has thanked: 93 times
Been thanked: 76 times
Contact:

Re: Continuing pic32mx270f256b timing issues

Post by Zane »

Hi Ben,

I am wondering, have you been able to make any head way with this problem or have any further suggestions of things we could try to resolve this problem. :D

Thanks

Zane

Post Reply