Page 1 of 1

SPI on 24FJ256GA110

Posted: Mon Nov 14, 2011 6:47 pm
by Mathy
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

Re: SPI on 24FJ256GA110

Posted: Wed Nov 16, 2011 5:39 pm
by Mathy
help :( :( :(

Re: SPI on 24FJ256GA110

Posted: Wed Nov 16, 2011 7:17 pm
by Mathy
I think I have spotted the problem.

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 / PORTB5
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 !

Re: SPI on 24FJ256GA110

Posted: Fri Nov 18, 2011 6:00 pm
by Benj
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.