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

PIC18F86K22 Port J [Solved]

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



Joined: 27 Sep 2005
Posts: 25

View user's profile Send private message

PIC18F86K22 Port J [Solved]
PostPosted: Thu Sep 22, 2011 10:58 am     Reply with quote

On a PIC18F86K22 I can't get get port J to function as digital I/O (all lines, specifically J2 and J3 appear to stuck as outputs). The seemingly relevant settings are:
Code:

#device adc=12
#device ICD=TRUE

#FUSES NOWDT
#FUSES ECM_IO                   //External clock, medium power
#FUSES PLLEN                            //4X HW PLL enabled
#FUSES NOPUT                      //No Power Up Timer
#FUSES MCLR                             //Master Clear pin enabled
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES BBSIZ2K                  //2K words Boot Block size
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOCPB                      //No Boot Block code protection
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#fuses SOSC_DIG         // Digital mode, I/O port functionality of RC0 and RC1
#fuses ABW8            // 8-bit bus (Micocontroller mode).
                     
#use delay(clock=48000000)

setup_external_memory(EXTMEM_DISABLE);

From the symptoms and the data sheet, it appears that the external memory interface is enabled. A curious observation is that when I delete the line immediately above that disables external memory, port E stops working as digital I/O (as expected), but port J starts acting as digital I/O, which is the opposite of what I expected.

Another curious observation is that the IDE shows that the ABW is set for a 20-bit bus, even though the ABW8 fuse should set it to an 8-bit bus (i.e., micro-controller mode). If I try to set the configuration bits for an 8-bit bus via the IDE (by un-checking the "Configuration bits set in code" box), after compiling, the bits go back to 20-bit mode. The LST file shows the ABW8 fuse as being set:
Code:

Configuration Fuses:
   Word  1: DB15   VREGSLEEP INTRC_HP SOSC_DIG NOXINST ECM_IO PLLEN FCMEN IESO
   Word  2: 7C79   NOPUT NOBROWNOUT BORV18 ZPBORM NOWDT WDT1048576
   Word  3: 8BC9   RTCOSC_T1 EXTADDRSFT ABW8 BW16 NOWAIT CCP2C1 ECCPE MSSPMSK7 MCLR
   Word  4: 0011   STVREN BBSIZ2K DEBUG
   Word  5: C00F   NOPROTECT NOCPB NOCPD
   Word  6: E00F   NOWRT NOWRTC NOWRTB NOWRTD
   Word  7: 400F   NOEBTR NOEBTRB

Some fuses have been forced to be compatible with the ICD debugger.

The line immediately above is disconcerting.

Software versions:
MPLAB v8.76 with an IDC3
CCS v4.124

Any ideas? I am stuck.

Regards,

Steve


Last edited by SteveW on Sun Sep 25, 2011 6:05 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 22, 2011 1:27 pm     Reply with quote

Quote:

I can't get get port J to function as digital I/O (all lines, specifically J2 and
J3 appear to stuck as outputs).

Post a short, compilable test program where you show the problem.
Show the code where you attempt to read pins J2 and J3. Show or tell
how you know that it's not working. Are you using a Watch window in
a debugger ? Probably. If so, try using printf to display the results of
the read operation. In other words, let's remove the possibility of a
problem in the debugger/IDE. Compile and run it in release mode.
SteveW



Joined: 27 Sep 2005
Posts: 25

View user's profile Send private message

PostPosted: Thu Sep 22, 2011 3:53 pm     Reply with quote

PCM Programmer,

Thank you for the reply. After more investigation, the port J pins are indeed set as inputs, but the internal pullups are not functioning. If I use an external pullup, operation is as expected. To enable pullups I use the command

port_j_pullups(TRUE);

Just in case this was implemented expecting individual pin selection, I tried

port_j_pullups(0xFF);

This doesn't work either.

There is nothing loading any of the pins I tried (J1-3).

The internal pullups are working fine on other ports.

I am not completely sure what you mean by "release mode". I have the ICD3 set as a programmer, not as a debugger. Is that what you mean?

Regards,

Steve
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 22, 2011 7:30 pm     Reply with quote

The built-in function for port_j_pullups() is writing to PortG, which is
incorrect. This is with vs. 4.124. I made a bit definition and a macro to
replace the built-in function. Try the code shown below. See if it fixes
the problem.
Code:

#include <18F86K22.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock=4000000)

#bit RJPU = getenv("SFR:PADCFG1").5
#define port_j_pullups(x)  x ? (RJPU = 1) : (RJPU = 0)

//==========================================
void main()
{
setup_external_memory(EXTMEM_DISABLE);
 
port_j_pullups(TRUE);

while(1);
}


And yes, by "Release Mode", I do mean using the ICD as a programmer,
and not as a debugger. MPLAB has a drop-down box to select either of
those two modes.
SteveW



Joined: 27 Sep 2005
Posts: 25

View user's profile Send private message

PostPosted: Thu Sep 22, 2011 9:21 pm     Reply with quote

Perfect! Thanks.

Where did you find the information that you used to determine that the PortJ function writes to PortG?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 22, 2011 10:07 pm     Reply with quote

I compiled the test program that I posted (but without the 2-lines above
main). Then I looked at the .LST file in both Symbolic and normal CCS
modes. It showed that the PortG was being accessed. That didn't seem
right, so I checked the PIC data sheet and confirmed it.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 25, 2011 2:51 pm     Reply with quote

I emailed CCS support about this just now. I also found that it affects
the enable pullups functions for PortD and PortE in addition to PortJ.
I told them about that too.
SteveW



Joined: 27 Sep 2005
Posts: 25

View user's profile Send private message

PostPosted: Sun Sep 25, 2011 6:03 pm     Reply with quote

Thank you for the explanation. Your approach will likely come in handy.
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