PIC32MZ2048EFG100 with powerfull SPI @50Mhz
Hi Ben
A SPI Bus needs 4 Pin:
CS =chip select
CLK =clock
MISO = Master data In, slave data out
MOSI = Master data out, slave data in
With Flowcode you can use a software SPI. This is very comfortable to use because you can choose a lot of pins for it. There is a little limitation, the speed is max. about 3Mhz.
To run at 50Mhz you need the Hardware SPI from the PIC.
There are 6 of them.
Each of this port has the clock on a specific pin:
SPI 1= D1
SPI 2= G6
SPI 3= B14
SPI 4= D10
SPI 5= F13
SPI 6= D15
The data inputs are a bit more flexible,but also with many restrictions.
Here too, Flowcode already offers comfotabel the right choice.
I used the SPI3 for a micro SD-card and it's working fine on 50Mhz!
I used in the same way the SPI 2 for the AD-converter but here makes the pin C4 problems
I can choose it , but it's not working as an input.
So I need a little info how to solve it.
PIC32MZ2048EFG100 with powerfull SPI @50Mhz
Moderator: Benj
-
- 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: PIC32MZ2048EFG100 with powerfull SPI @50Mhz
Hello,
I have checked the v8 code generation and this code is being added to the top of the main function which should turn off the analog input mode and switch to the digital input mode.
The definitions for the SPI remap also look to be correct.
Not sure what else might be causing the pin not to work as an input. What other functions does the pin have? Maybe these also need manually switching off?
From scanning the datasheet there is the EBIOE pin functionality controlled via the CFGEBIC register and the PMRD pin functionality controlled via the PMCON register but both seem to be disabled by default. You could maybe try setting both registers to 0 using a C icon to see if this makes any difference.
Other then this might be worth checking the Microchip site for the errata document to see if it's a known bug on the silicon.
I have checked the v8 code generation and this code is being added to the top of the main function which should turn off the analog input mode and switch to the digital input mode.
Code: Select all
int main()
{
ANSELA = 0x0000;
ANSELB = 0x0000;
ANSELC = 0x0000;
ANSELD = 0x0000;
ANSELE = 0x0000;
ANSELF = 0x0000;
ANSELG = 0x0000;
Code: Select all
#define MX_SPI_MISO_RPINR_1 SDI2R
#define MX_SPI_MISO_RP_1 10
From scanning the datasheet there is the EBIOE pin functionality controlled via the CFGEBIC register and the PMRD pin functionality controlled via the PMCON register but both seem to be disabled by default. You could maybe try setting both registers to 0 using a C icon to see if this makes any difference.
Code: Select all
CFGEBIC = 0;
PMCON = 0;
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: PIC32MZ2048EFG100 with powerfull SPI @50Mhz
Hi Ben
It's the same even if I insert the c-code.
But there may be is a hint.
Analog input AN22 on pin C1 is not working too. I mean I can config as input and it shows nothing, just like a noise, as if the multiplexer is not set to the (correct) input.
It's the same even if I insert the c-code.
But there may be is a hint.
Analog input AN22 on pin C1 is not working too. I mean I can config as input and it shows nothing, just like a noise, as if the multiplexer is not set to the (correct) input.
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: PIC32MZ2048EFG100 with powerfull SPI @50Mhz
Hi Ben
I have checked various registers in the pdf and I compared with value from the register in my program.
I think what I checked is ok. I can not found something wrong. But I found a pin what is working for the SPI 2 as MiSO. => D3
Unfortunately I can not change the hardware anymore. There is a hint again. D3 is not an analog input. And general in my program are the analog Input not doing well too. The analog input look like there are working , but if I change the input, the value from the AD don't change ( like the SPI2 Miso)
So to check some more register is simple me for to do. If you now some more to check please let me know
I have checked various registers in the pdf and I compared with value from the register in my program.
I think what I checked is ok. I can not found something wrong. But I found a pin what is working for the SPI 2 as MiSO. => D3
Unfortunately I can not change the hardware anymore. There is a hint again. D3 is not an analog input. And general in my program are the analog Input not doing well too. The analog input look like there are working , but if I change the input, the value from the AD don't change ( like the SPI2 Miso)
So to check some more register is simple me for to do. If you now some more to check please let me know
Code: Select all
FCL_REGISTER_VAL[0] = ANSELC;
FCL_REGISTER_VAL[1] = SDI1R;
FCL_REGISTER_VAL[2] = SDI2R;
FCL_REGISTER_VAL[3] = SDI3R;
FCL_REGISTER_VAL[4] = SPI1CON;
FCL_REGISTER_VAL[5] = SPI2CON;
FCL_REGISTER_VAL[6] = SPI3CON;
FCL_REGISTER_VAL[7] = TRISC;
FCL_REGISTER_VAL[8] = CFGEBIC;
FCL_REGISTER_VAL[9] = PMCON;
FCI_TOSTRING(FCL_REGISTER_VAL[FCL_LINE_NR], FCL_OUTPUT_LINE[1],10);