CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Sample code to remap I/O for IC24FJ256GB110?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hobgoblin



Joined: 10 Sep 2003
Posts: 7

View user's profile Send private message

Sample code to remap I/O for IC24FJ256GB110?
PostPosted: Fri Jun 27, 2008 7:33 am     Reply with quote

Hi,
Can someone please provide a PICC PCD code example for how to re-map port pins?

We are about to buy the compiler and I'm trying to write some code for it in advance but I can't find any code examples anywhere of how to do this. The chip we're using is the IC24FJ256GB110 but I'm sure it doesn't matter which chip as long at it will work for a 24F.

Thanks in advance

Adrian
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 27, 2008 11:51 am     Reply with quote

I don't think very many people on this forum use the PCD compiler.
Mostly we use PCM or PCH (16F or 18F). You can tell that by reading
the posts from day to day.
Storic



Joined: 03 Dec 2005
Posts: 182
Location: Australia SA

View user's profile Send private message Send e-mail

PostPosted: Sat Jun 28, 2008 6:33 am     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=33062&highlight=pinselect

this link shows the #pin_Select as shown below sample

//********** ASSIGN PIN TO PERIPHICALS
//RS232 PINS
#Pin_select U1TX=PIN_B0
#Pin_select U1RX=PIN_B1

//PWM 0-10 V REF OUT
#Pin_select OC1=PIN_B9

//PWM OUTPUT PINS
#Pin_select OC2=PIN_C5
#Pin_select OC3=PIN_B6
#Pin_select OC4=PIN_C2
#Pin_select OC5=PIN_C7

I am now working on the 24FJ256GB106 micro.
well I have stopped for now until my PCB is ready.

the BG (USB) will be a feature I want to use (once I get to review more samples) Wink Smile
_________________
What has been learnt if you make the same mistake? Wink
hobgoblin



Joined: 10 Sep 2003
Posts: 7

View user's profile Send private message

RE: Sample code to remap I/O for IC24FJ256GB110?
PostPosted: Mon Jun 30, 2008 4:35 am     Reply with quote

Hi Storic,

That's great, many thanks, but is this all that is required?

The reason I ask is because Microchip gives example C code for their C30 C compiler that includes dedicated assembly code to unlock and relock the pin that ties up with the same example in the data sheet for the PIC24FJ256GB110.

As I said, up until now I have found no examples of how PICC does it.

Could you please confirm if your PICC example...

#Pin_select U1TX=PIN_B0
#Pin_select U1RX=PIN_B1

...generates and invokes this pin unlock/lock code too? (see below)


Taken from Microchip compiler example:

//INPUTS **********************

//U2RX = RP19
RPINR19bits.U2RXR = 19;

//OUTPUTS *********************

//RP25 = U2TX
RPOR12bits.RP25R = U2TX_IO;

/********************************
* Function: lockIO
* Preconditions: None.
* Overview: This executes the necessary process to set the IOLOCK bit
* to lock I/O mapping from being modified.
* Input: None.
* Output: None.
********************************/
void lockIO(){
asm volatile ("mov #OSCCON,w1 \n"
"mov #0x46, w2 \n"
"mov #0x57, w3 \n"
"mov.b w2,[w1] \n"
"mov.b w3,[w1] \n"
"bset OSCCON, #6");
}

********************************
* Function: unlockIO
* Preconditions: None.
* Overview: This executes the necessary process to clear the IOLOCK
* bit to allow I/O mapping to be modified.
* Input: None.
* Output: None.
********************************/
void unlockIO(){
asm volatile ("mov #OSCCON,w1 \n"
"mov #0x46, w2 \n"
"mov #0x57, w3 \n"
"mov.b w2,[w1] \n"
"mov.b w3,[w1] \n"
"bclr OSCCON, #6");
}

Thanks again in advance,

Adrian
Storic



Joined: 03 Dec 2005
Posts: 182
Location: Australia SA

View user's profile Send private message Send e-mail

PostPosted: Wed Jul 02, 2008 3:39 pm     Reply with quote

I believe it does do as microchip suggest, confirmation can come from CCS support, Confused I had a look through my old email from CCS Support when I first tried to do Pin select and was not able to support your question.
Wink Have you checked the PCWHD manual to see if this is shown.
_________________
What has been learnt if you make the same mistake? Wink
Guest








PostPosted: Thu Jul 10, 2008 3:33 am     Reply with quote

ok, thanks.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group