SPI on 24FJ256GA110

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times

SPI on 24FJ256GA110

Post 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

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times

Re: SPI on 24FJ256GA110

Post by Mathy »

help :( :( :(

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times

Re: SPI on 24FJ256GA110

Post 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 !

User avatar
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

Post 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.

Post Reply