View previous topic :: View next topic |
Author |
Message |
martind1983
Joined: 22 Mar 2013 Posts: 16
|
PIC24FJ64GA002 selectable peripheral pins |
Posted: Tue Apr 02, 2013 5:17 am |
|
|
Hi.
I have question.
I want to use PIC24FJ64GA002 16 bit PIC which has any selectable inputs for peripherals . Simply told, you can use some of peripheral I/O's with any selectable hardware pin on MCU.
I want to know, are there any functions in CCS PCD compiler for this purpose? I think, that some directives like #USE SPI solve it with options like ENABLE=PIN, SDI=PIN, but there is only one I know.
What external interrupts and other? Are there any functions for this purpose? While I didn't find there any option for this purpose of selecting pins to peripheral. So when somebody else who already used or is still using 16bit PIC MCU's could help me. I would be very thankful.
Thanks Martin. |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Tue Apr 02, 2013 5:44 am |
|
|
See the #pin_select in CCS manual |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Apr 02, 2013 6:02 am |
|
|
as well, open the processor header file to see what is allowed !
and consult the processor datasheet, as not all pins can be all things !!! |
|
|
martind1983
Joined: 22 Mar 2013 Posts: 16
|
|
Posted: Tue Apr 02, 2013 6:17 am |
|
|
temtronic wrote: | as well, open the processor header file to see what is allowed !
and consult the processor datasheet, as not all pins can be all things !!! |
I have already seen datasheet and header file. It was the reason I asked questions about this topic here. I could find any standard information about it. |
|
|
martind1983
Joined: 22 Mar 2013 Posts: 16
|
|
Posted: Tue Apr 02, 2013 6:20 am |
|
|
alan wrote: | See the #pin_select in CCS manual |
Thanks for your hint. It is it. It helped |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Tue Apr 02, 2013 7:15 am |
|
|
As a general comment, I find the most reliable way is to keep it simple.
The RS232 serial command (for instance), has an option to tell it to use the hardware UART. So use the select to say 'what pins this uses', and then use the serial command in this form. The same with SPI. So for the UART:
Code: |
//Now setup the UART pins
#pin_select TX2=PIN_C0
#pin_select RX2=PIN_C1 //Select pins for UART2
#use rs232 (baud=9600,parity=N,UART2,bits=8,errors)
//Tell the compiler you want to use the hardware UART2.
|
The problem is that if you try to do it with the #use RS232 or #use SPI, you would need to look in the assembler to find out if it is genuinely using the SPI/UART, rather than doing a software emulation. Unfortunately some compilers get the mapping right, and other don't. By directly saying 'I want UART2 TX/RX on these pins', and then 'I want to talk to UART2', you know what is going on....
I feel it is safer, and it seems to keep working through compiler versions....
Best Wishes |
|
|
|