Hello,
I have a problem with the SPI comonent on this chip.
I have no problem to use SPI with the 18F family but with the 24FJ, I have nothing on the SPI 1 and SP2. I have a low level on the SDO and CLK pin.
There is a little bug on the SPI component, you forget to put multipleallowed to 1 instead of 0.
Thanks for your help,
Mathy
SPI on 24FJ256GA110
Moderator: Benj
Re: SPI on 24FJ256GA110
I think I have spotted the problem.
In your PIC16BIT_SPI_Legacy.c file, SDO is assign to RP5 / RB5 :
The problem is RP5 isn't connected to RB5 but RD15 !
RB5 is connected to RP18.
Haw can I change this ? I don't understand how works the peripheral pin select feature.
I think I have to replace RPOR2 by RPOR9 but I don't understand the complete line : RPOR2 = (RPOR2 & 0x00FF) | 0x0700;
can you explain what I have to change and what is the method to find by myself for the others pins ?
Thank you !
In your PIC16BIT_SPI_Legacy.c file, SDO is assign to RP5 / RB5 :
Code: Select all
RPINR20 = (RPINR20 & 0xFF00) | 0x04; //Assign SDI - RP4 / PORTB4
RPOR1 = (RPOR1 & 0x00FF) | 0x0800; //Assign SCK - RP3 / PORTB3
RPOR2 = (RPOR2 & 0x00FF) | 0x0700; //Assign SDO - RP5 / PORTB5RB5 is connected to RP18.
Haw can I change this ? I don't understand how works the peripheral pin select feature.
I think I have to replace RPOR2 by RPOR9 but I don't understand the complete line : RPOR2 = (RPOR2 & 0x00FF) | 0x0700;
can you explain what I have to change and what is the method to find by myself for the others pins ?
Thank you !
- 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: SPI on 24FJ256GA110
Hello,
The remapping feature is described in the ports section of the device datasheet. Looking through the registers should help to show you what you need to do.
Each command is doing the following.
RPINR20 = (RPINR20 & 0xFF00) | 0x04; //Assign SDI - RP4 / PORTB4
Assign the bottom 8-bits of register RPINR20 with 0x04 and retain the information in the upper 8-bits.
Presumably RPINR20 is the SPI SDI input and 0x04 signifies RP4.
For the outgoing registers the pin becomes dedicated to the register and the peripheral is the value.
RPOR1 = (RPOR1 & 0x00FF) | 0x0800; //Assign SCK - RP3 / PORTB3
Assign the top 8-bits of register RPOR1 with 0x80 and retain the information in the lower 8-bits.
Presumably RPOR1 is the register dedicated to RP2 and RP3 and 0x80 signifies the SCK output.
The remapping feature is described in the ports section of the device datasheet. Looking through the registers should help to show you what you need to do.
Each command is doing the following.
RPINR20 = (RPINR20 & 0xFF00) | 0x04; //Assign SDI - RP4 / PORTB4
Assign the bottom 8-bits of register RPINR20 with 0x04 and retain the information in the upper 8-bits.
Presumably RPINR20 is the SPI SDI input and 0x04 signifies RP4.
For the outgoing registers the pin becomes dedicated to the register and the peripheral is the value.
RPOR1 = (RPOR1 & 0x00FF) | 0x0800; //Assign SCK - RP3 / PORTB3
Assign the top 8-bits of register RPOR1 with 0x80 and retain the information in the lower 8-bits.
Presumably RPOR1 is the register dedicated to RP2 and RP3 and 0x80 signifies the SCK output.
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