Hi,
I can't figure out why I've got this weird behaviour.
dsPIC33 misreads data from SPI after each power up
but it reads the correct data from the same SPI device after a MCLR reset
Anybody got a suggestion?
SPI little problem
Re: SPI little problem
Hi,
Which development board are you using ?
Can you attach the schematics of your connections ?
Can you add a little delay at the start-up ?
Regards,
Filip.
Which development board are you using ?
Can you attach the schematics of your connections ?
Can you add a little delay at the start-up ?
Regards,
Filip.
-
- Posts: 282
- Joined: 17 Jun 2009 10:42
Re: SPI little problem
Hi,
I thought that mikroe library is taking care of pins when remapping them, but it looks like I was wrong again.
Although this is the right mapping of my pins:
I had to correctly set the individual pins manually, otherwise it wasn't working, like I've said in the first post.
So the correct settings for the pins in TRIS and PORT and LAT for these particular pins is:
My mistake was previously I left
Now it works fine.
Thanks mikroe for not letting us know the importance of manually setting these pins the right way.
Why did you ever invent the remappable library when I could have done it myself as:
I mean if you didn't bother setting the pins the right way in your remappable library, then why bother at all?
Or you could have warned us:
Funny thing is someone else had a similar problem with remappable pins, 7 years ago:
viewtopic.php?t=61661
I thought that mikroe library is taking care of pins when remapping them, but it looks like I was wrong again.
Although this is the right mapping of my pins:
Code: Select all
PPS_Mapping_NoLock(25, _INPUT, _SDI2) ; // SPI2 Data Input
PPS_Mapping_NoLock(20, _OUTPUT, _SDO2) ; // SPI2 Data Output
PPS_Mapping_NoLock(48, _INPUT, _SCK2IN) ; // SPI2 Clock Input /* Choose an RP pin
PPS_Mapping_NoLock(48, _OUTPUT, _SCK2OUT) ; // SPI2 Clock Output capable of In/Out for the Clock */
So the correct settings for the pins in TRIS and PORT and LAT for these particular pins is:
Code: Select all
Out High for SPI_SCK
In High for SPI_SDI
Out High for SPI_SDO
Code: Select all
Out Low for SPI_SCK
In Low for SPI_SDI
Out High for SPI_SDO
Thanks mikroe for not letting us know the importance of manually setting these pins the right way.
Why did you ever invent the remappable library when I could have done it myself as:
Code: Select all
RPINR22bits.SCK2R = 0b0110000 ; // RP48 ; // SCK2 SPI2 Clock Input SCK2IN RC0 = Out High for SPI_SCK;
RPINR22bits.SDI2R = 0b0011001 ; // RP25 ; // SDI2 SPI2 Data Input SDI2 RA9 = In High for SPI_SDI;
RPOR5bits.RP48R = 0b001001 ; // RP48 ; // RPn tied to SPI2 Clock Output SCK2OUT RC0 = Out High for SPI_SCK;
RPOR0bits.RP20R = 0b001000 ; // RP20 ; // RPn tied to SPI2 Data Output SDO2 RA4 = Out High for SPI_SDO;
RPOR3bits.RP40R = 0b001010 ; // RP40 ; // RPn tied to SPI2 Slave Select SS2 RB8 = Out Low pt SPI_Disabled;
Or you could have warned us:
And thanks for asking me the wrong questions; like schematic or board development got anything to do with a piece of code not working at power up, but working after MCLR reset.pay attention brothers and sisters, I'm only giving you part of the code, you have to figure out the missing part for yourself
Funny thing is someone else had a similar problem with remappable pins, 7 years ago:
viewtopic.php?t=61661
Re: SPI little problem
Hi,
First of all, I apologize for the issue with the PPS library, we will see what is going on there.
Next time, please add as much information you can in order to get the best possible support.
Regards,
Filip.
First of all, I apologize for the issue with the PPS library, we will see what is going on there.
You didn't specify anything related to your project/MCU/hardware/compiler version so I had to start somewhere - ask some of the question that may shed some light onto this matter.And thanks for asking me the wrong questions; like schematic or board development got anything to do with a piece of code not working at power up, but working after MCLR reset.
Next time, please add as much information you can in order to get the best possible support.
Regards,
Filip.