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 CCS Technical Support

MPLAB X IDE v2.35 #PIN_SELECT

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



Joined: 04 Aug 2015
Posts: 16
Location: United States

View user's profile Send private message

MPLAB X IDE v2.35 #PIN_SELECT
PostPosted: Tue Aug 04, 2015 3:34 pm     Reply with quote

Hi everyone,

I am using the PIC18F67J94. I am currently experiencing some problems with the #pin_select from the CCS C Compiler manual. I am trying to assign software UARTs to re-mappable pins. I am using the list from RP0 to RP47 to assign three different UARTs but I get errors back saying this:

Here is my code below:

[img]http://www.microchip.com/forums/download.axd?file=0;883269&where=&f=PIC18F67J94%20MPLAB%20..._SELECT%20ERRORS.PNG[/img]

[img]http://www.microchip.com/forums/download.axd?file=1;883269&where=&f=PIC18F67J94%20MPLAB%20X%20IDE%20PIN_SELECT.PNG[/img]

How can I fix those errors? Would it be because of a version problem with MPLAB X IDE?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 5:07 pm     Reply with quote

Your links don't work.

How to post an image on the CCS forum:
Go to this website: http://postimage.org/
Upload your image. Select family safe. Then click the first button for
"Hotlink to Forum" to get a link to the image.
Then go to the CCS forum and type Ctrl-V to paste the link into a post.

If postimage.org doesn't work in your country, then use Google to find
another free image hosting site for forums.
12Lapointep



Joined: 04 Aug 2015
Posts: 16
Location: United States

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 5:39 pm     Reply with quote


imgurl


20mb image hosting
Ttelmah



Joined: 11 Mar 2010
Posts: 19511

View user's profile Send private message

PostPosted: Wed Aug 05, 2015 2:54 am     Reply with quote

There are three separate problems of increasing importance:

First, the clock, and UART setup should be _before_ you load library code. Sequence must always be:
Processor setup
Fuses
CLOCK, UART etc..

Only then load things like stdlib.

At the moment this doesn't matter, since you are not getting this far.

Then the second problem is trying to setup U3RTS, and U3CTS with the select statement. This could be right on some of the DsPIC's which have hardware RTS/CTS, but your chip does not. You cannot use SELECT statements for these. They have to be setup as _software_ controlled lines in the #USE RS232 statement. This means you have to enable the receive buffer mode. This gets rid of the last two error lines.

The main one, is that code is behaving as if it thinks the chip is in extended microcontroller mode. Can't be, since this is not supported by the chip!. It's behaving as the 97J would, if you attempted to select these pins, and had the external memory bus enabled.

I'd say you need to talk to CCS. Do a simple demo program just to show the problem, like:
Code:

#include <18F67J94.h>
#fuses PR, MS, STVREN, SOSC_DIG, NOPLL, NODEBUG, BROWNOUT_SW, NOWDT, NOPROTECT
#fuses NOIOL1WAY, NOXINST, CLOCKOUT, WINDIS
#device ADC=16
#use delay(crystal=8000000)

//You _must_ configure the UART before loading code that may use it.
#PIN_SELECT U1RX=PIN_A0
#PIN_SELECT U1TX=PIN_A3

#PIN_SELECT U2RX=PIN_E0
#PIN_SELECT U2TX=PIN_G1

#PIN_SELECT U3RX=PIN_D1
#PIN_SELECT U3TX=PIN_D2
//This UART does _not_ have hardware RTS/DTS

#USE RS232 (UART1, BAUD=115200, BRGH1OK, BITS=8, PARITY=N, ERRORS, STREAM=RS422)
#USE RS232 (UART2, BAUD=9600, BRGH1OK, BITS=8, PARITY=N, ERRORS, STREAM=RS485)
#USE RS232 (UART3, BAUD=9600, BRGH1OK, BITS=8, PARITY=N, ERRORS, STREAM=RS232, RTS=PIN_D3, CTS=PIN_D4, RECEIVE_BUFFER=8)
//Setup software RTS/DTS here - note the receive buffer - you can't have
//flow control without a buffer.

void main()
{
   setup_lcd(LCD_DISABLED);

   while(TRUE)
   {


      //TODO: User Code
   }

}


and ask them what is wrong.

If you look carefully at the errors, you will see that it is accepting pin G1, which is one of the pins not used by the external address bus. So a compiler issue.
12Lapointep



Joined: 04 Aug 2015
Posts: 16
Location: United States

View user's profile Send private message

PostPosted: Wed Aug 05, 2015 5:17 am     Reply with quote

Thank you for the post. It helped a lot to understand what is going on. As of now, I believe it is a version issue but I cannot wrap my head around it.

Why is PIN_G1 being accepted whereas the other ones are not? I would need more explanation on this part of the post.
12Lapointep



Joined: 04 Aug 2015
Posts: 16
Location: United States

View user's profile Send private message

PostPosted: Wed Aug 05, 2015 9:23 am     Reply with quote

The PIC18FxxJ94 family is really picky about which pins can be assigned to which peripheral. The compiler is generating errors because you're trying to assign pins to peripherals that aren't allowed. Refer to tables 11-13 and 11-14 in the family datasheet for lists of pins that can be assigned to which peripheral. For example for UART1 only the following pins can be assigned as the U1RX pin:

RP3 - PIN_A3
RP7 - PIN_B3
RP11 - PIN_C2
RP15 - PIN_C3
RP19 - PIN_C7
RP23 - PIN_D3
RP27 - PIN_D7
RP31 - PIN_E7
RP35 - PIN_F5
RP39 - PIN_G1
RP43 - PIN_F3

And the only the following pins can be assigned as the U1TX pin:

RP2 - PIN_A2
RP6 - PIN_A6
RP10 - PIN_A7
RP14 - PIN_B2
RP18 - PIN_C6
RP22 - PIN_D2
RP26 - PIN_D6
RP30 - PIN_E2
RP34 - PIN_E6
RP38 - PIN_F7
RP42 - PIN_G2
RP46 - PIN_G0


Here is the answer I got from CCS Support. The PIC18F67J94 has four groups of remappable pins. This is why I got errors on my pins. I overlooked a part of the datasheet that was fairly important to the project.
Ttelmah



Joined: 11 Mar 2010
Posts: 19511

View user's profile Send private message

PostPosted: Wed Aug 05, 2015 10:50 am     Reply with quote

Brilliant.
A nice quick answer, and in the end 'simple', but does rather restrict things.

Smile
12Lapointep



Joined: 04 Aug 2015
Posts: 16
Location: United States

View user's profile Send private message

PostPosted: Wed Aug 05, 2015 11:07 am     Reply with quote

It is fairly simple. Just not explained very well in the datasheet. Flipping pins through my design and adding jumpers was the only option for the prototype.

Thank you very much for your help though.
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