PIC32MZ2048EFH why running exactly 25 times too slow?

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
jks45
Posts: 7
Joined: 08 Dec 2018 22:37

PIC32MZ2048EFH why running exactly 25 times too slow?

#1 Post by jks45 » 06 Jun 2019 18:28

I had an I2C program running perfectly, but then noticed how slow it was running with my scope so I made a tiny program to test the speed. Every action runs 25 times too slow. I hope to be embarrassed by something simple I'm not seeing, but right now I have to stop my programming efforts until I know what is wrong.
Attachments
MZ2048 settings 3 and 4.JPG
MZ2048 settings 3 and 4.JPG (112.27 KiB) Viewed 2512 times
MZ2048 settings 1 and 2.JPG
MZ2048 settings 1 and 2.JPG (140.01 KiB) Viewed 2512 times
MZ2048 scope prog.JPG
MZ2048 scope prog.JPG (30.38 KiB) Viewed 2512 times

brandonb
Posts: 105
Joined: 24 Jan 2013 03:24

Re: PIC32MZ2048EFH why running exactly 25 times too slow?

#2 Post by brandonb » 06 Jun 2019 21:26

are you using this https://microchipdeveloper.com/32bit:mz-osc-frc as primary osc ? seems like you setting would be
4Mhz = 8Mhz frc / 8 * 128 / 32

the pLL input divider would imagine be set up lower to match 8Mhz / 8 setting that your feeding the pLL

jks45
Posts: 7
Joined: 08 Dec 2018 22:37

Re: PIC32MZ2048EFH why running exactly 25 times too slow?

#3 Post by jks45 » 06 Jun 2019 23:31

brandonb wrote:are you using this https://microchipdeveloper.com/32bit:mz-osc-frc as primary osc ? seems like you setting would be
4Mhz = 8Mhz frc / 8 * 128 / 32

the pLL input divider would imagine be set up lower to match 8Mhz / 8 setting that your feeding the pLL
I'm using EasyPIC Fusion v7 board with PIC32MZ ETH CARD and all default settings as shown. When I used the PIC32MX795F512L I had very complex programs running extremely accurately with default settings. I even swapped three other ETH CARDS - exactly same -25 times slow for every command. I'm hoping it is a simple setting, but nothing I tried made any difference.

brandonb
Posts: 105
Joined: 24 Jan 2013 03:24

Re: PIC32MZ2048EFH why running exactly 25 times too slow?

#4 Post by brandonb » 07 Jun 2019 02:58

looks like you have a 24 Mhz External Clock on your card that is fed into the pic32mz. use this link to calculate what config bits to set for what you desire https://microchipdeveloper.com/32bit:mz-osc.

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: PIC32MZ2048EFH why running exactly 25 times too slow?

#5 Post by filip.grujcic » 07 Jun 2019 15:51

Hello,

Your oscillator and clock settings are set incorrectly, more precisely, they are set to their default values which compiler falls back to each time you select a different MCU.

Load the configuration scheme from the attachment(Ctrl + Shift + E -> Load Scheme) and tell the compiler that the MCU frequency is 200MHz, after that your code should work without problems.

Kind regards,
Attachments
P32MZ2048EFH_PLL_24_to_200MHz.zip
(1.53 KiB) Downloaded 106 times
Filip Grujcic

jks45
Posts: 7
Joined: 08 Dec 2018 22:37

Re: PIC32MZ2048EFH why running exactly 25 times too slow?

#6 Post by jks45 » 07 Jun 2019 18:26

WOW! Instant success! Thank you so much filip.grujcic and thank you brandonb for the great information. It was so easy and fast! I designed a system using four PIC32MZ2048EFH MCU's controlling: multiple motors, three different accelerometers (SPI and I2C), four Manchester code calibratable optical sensors, four SPI magnetic rotational angle sensors etc.. I plan to use the touch screen that came with the EasyPIC Fusion v7 board since the board isn't hardwired to use PPS to the "USB UART A or USB UART B" ports like I did with the PIC32MX795F512L. Using the USB to the USART Terminal was so handy before to see ascii converted values as I tested the code for each sensor chip. I have never used the Mikro ICD since I thought it wouldn't let me see inputs from external devices in real time running code. Maybe it can...I don't know. I have each MCU dedicated to separate tasks and then communicating (SPI) with each other to cooperate for the overall system. (Self balancing robot) I'm planning on extending the MCU programming wires from the EasyPIC Fusion v7 board to switches so I can leave the four MCU's in-circuit and yet still program each separately. I know that is frowned upon, but it is too cumbersome to unplug the PIC32MZ ETH CARD's for each as I work on the code. I did this with multiple PIC18F4522's and others with great success. Shared the work load and had them communicate with each other. Multiple processors beats gigantic code and timing issues when having to timeshare tasks. I never even used the interrupt function once since motor motion profiles (Accelerate, constant speed, decelerate) can't be interrupted anyway. I plan when each sensor can be read and poll it when the time is appropriate. This is the advantage of sharing the work with multiple MCU's.
Attachments
MZ2048 scope correct.JPG
MZ2048 scope correct.JPG (27.59 KiB) Viewed 2465 times

Post Reply

Return to “mikroBasic PRO for PIC32 General”