View previous topic :: View next topic |
Author |
Message |
hobgoblin
Joined: 10 Sep 2003 Posts: 7
|
Sample code to remap I/O for IC24FJ256GB110? |
Posted: Fri Jun 27, 2008 7:33 am |
|
|
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
|
|
Posted: Fri Jun 27, 2008 11:51 am |
|
|
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
|
|
Posted: Sat Jun 28, 2008 6:33 am |
|
|
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) _________________ What has been learnt if you make the same mistake? |
|
|
hobgoblin
Joined: 10 Sep 2003 Posts: 7
|
RE: Sample code to remap I/O for IC24FJ256GB110? |
Posted: Mon Jun 30, 2008 4:35 am |
|
|
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
|
|
Posted: Wed Jul 02, 2008 3:39 pm |
|
|
I believe it does do as microchip suggest, confirmation can come from CCS support, 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.
Have you checked the PCWHD manual to see if this is shown. _________________ What has been learnt if you make the same mistake? |
|
|
Guest
|
|
Posted: Thu Jul 10, 2008 3:33 am |
|
|
ok, thanks. |
|
|
|