Hi Ben
First the good news.
IRQ:
The Irq is working nice with FC7. Just choose rollover and prescaler. And the IRQ frequenz is showing at the screen.
With the osciloscope controlled. It's perfect 2.000kHz.
Delay:
The same with the delay. Choose 1 Sec and its one second in the scope......
I2c:
Now the not so good side...
I choosed 1Mega but the result is 532kHz
SPI:
I choosed maximal (div2) and expect 50Mhz but the result is 3.2 MHz
UART
I choosed 1200Bd (Bitlength 833uSec and expect 2x833uSec=1.66mSec but the result is 3.33mSec
for a control I connected the uart to a computer. For a comunication I have to reduce the speed in the computer.
All the measurements results are in the PDF.
Can You help me to fix this few problems?
PIC32MZ2048 SPI Uart i2c speed
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
- 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: PIC32MZ2048 SPI Uart i2c speed
Hello,
Sorry for the delay and thanks for letting us know.
Is it possible for you to attach the Flowcode project file so we can look at things like the config etc. I'll investigate to see if there are any additional hidden prescalers that could be effecting the comms peripherals speed.
Sorry for the delay and thanks for letting us know.
Is it possible for you to attach the Flowcode project file so we can look at things like the config etc. I'll investigate to see if there are any additional hidden prescalers that could be effecting the comms peripherals speed.
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
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: PIC32MZ2048 SPI Uart i2c speed
Hi Ben
Thank you for the support.
Here the Flowcode project file and a plan which pin I used for the scope. I used PICkit3 as programmer.
Thank you for the support.
Here the Flowcode project file and a plan which pin I used for the scope. I used PICkit3 as programmer.
- 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: PIC32MZ2048 SPI Uart i2c speed
Hello
The SPI peripheral has a bit which chooses either the PBCLK2 or the REFCLKO1 as the clock source. The PBCLK2 is the default setting. Currently I'm not sure how this clock is adjusted. Looking into it now.
You can try switching to the REFCLKO1 by using the following C code after initialising the SPI component.
The I2C Baud calculation looks a bit over complicated so this probably needs investigating too.
This is the PIC32 version.
The is the PIC16 version - note no floating point calculations.
The SPI peripheral has a bit which chooses either the PBCLK2 or the REFCLKO1 as the clock source. The PBCLK2 is the default setting. Currently I'm not sure how this clock is adjusted. Looking into it now.
You can try switching to the REFCLKO1 by using the following C code after initialising the SPI component.
Code: Select all
SPI1CONbits.MCLKSEL = 1;
This is the PIC32 version.
Code: Select all
#define MX_I2C_HW_BAUD ((((1.0f/ (2.0f * MX_I2C_BAUD_X)) - (0.104f/1000000.0f)) * MX_CLK_SPEED) - 2 )
Code: Select all
#define MX_I2C_HW_BAUD ((MX_CLK_SPEED / MX_CLKS_PER_INST) / MX_I2C_BAUD_X) - 2
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
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: PIC32MZ2048 SPI Uart i2c speed
Hi Ben
I tried to set the bit in SPI2CON but then is the hardware spi not working and the software is not bether.
I found an another problem in FC7.
startet the board in hardware spi2 and it's run on 50Mhz. Perfect.
Ichanched to software, the speed goes down to 3Mhz.
go back to hardware and it's slow too.
If I toggle the hardware/software without compiele it's slow 3Mhz. (Both hard and soft spi)
The good thing is.... if I go change to hardware 1 and back to hardware2 it's 50Mhz again.
I trie now the I2c....
But do you have a good idea for the UART?
I tried to set the bit in SPI2CON but then is the hardware spi not working and the software is not bether.
I found an another problem in FC7.
startet the board in hardware spi2 and it's run on 50Mhz. Perfect.
Ichanched to software, the speed goes down to 3Mhz.
go back to hardware and it's slow too.
If I toggle the hardware/software without compiele it's slow 3Mhz. (Both hard and soft spi)
The good thing is.... if I go change to hardware 1 and back to hardware2 it's 50Mhz again.
I trie now the I2c....
But do you have a good idea for the UART?
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: PIC32MZ2048 SPI Uart i2c speed
Hi Ben
@UART
@I choosed 1200Bd (Bitlength 833uSec and expect 2x833uSec=1.66mSec but the result is 3.33mSec
@for a control I connected the uart to a computer. For a comunication I have to reduce the speed in the computer.
I have still the problem with the speed of the uart. It's factor 2 wrong.
And is it possible to add some higher speed in the menue?
230400
460800
921600
regards
Stefan
@UART
@I choosed 1200Bd (Bitlength 833uSec and expect 2x833uSec=1.66mSec but the result is 3.33mSec
@for a control I connected the uart to a computer. For a comunication I have to reduce the speed in the computer.
I have still the problem with the speed of the uart. It's factor 2 wrong.
And is it possible to add some higher speed in the menue?
230400
460800
921600
regards
Stefan
- 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: PIC32MZ2048 SPI Uart i2c speed
Hi Stefan,
I've answered you here in a move to try and fix the speed problems on PIC32.
viewtopic.php?f=78&t=20139#p88753
The datasheets don't make things easy and a fix for one device seems to cause problems on other device in the same family. Anyway we should be able to get to the bottom of things if we take it a device at a time and focus on what's not working.
I've answered you here in a move to try and fix the speed problems on PIC32.
viewtopic.php?f=78&t=20139#p88753
The datasheets don't make things easy and a fix for one device seems to cause problems on other device in the same family. Anyway we should be able to get to the bottom of things if we take it a device at a time and focus on what's 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