Jump to content
Edward Mulder

18F2520 Porta.6,7 Not Outputs

Recommended Posts

Hello all,

 

I just tried to port my routines for an LCD from a PIC16 to an 18F2520 (DIP-28).

When I use RC.0-3 for the data and RA.4 and 5 for the E/RS lines, everything

works fine.

 

When I try to run the plug-in, using RA.6 and RA.7, I can´t see any activation

of the output pins. Oscillator mode is _OSC_INTIO67_1H, so these pins should

be available for I/O.

 

Running a small check like this confirms the behaviour:

porta = 0x10;

porta = 0x20;

porta = 0x40; //no activation

porta = 0x80; //no activation

 

Anbody knows what I am missing? I have not built the circuit yet, I first wanted to run

the program on the plug-in simulator.

 

Edward

Share this post


Link to post
Share on other sites

Hi

 

Did you check if any of the pins that you are using have some special functions like analog inputs~'

 

If they do, on power up they default to analog inputs and you have to configure them for digital I/O.

 

 

 

Best regards

Jorge

Share this post


Link to post
Share on other sites

Hi Jorge,

 

This is what I did to disable the analog inputs and activate the internal oscillator:

 

#include <stdlib.h>

#include <string.h>

#include <ctype.h>

#include <system.h>

 

#pragma DATA _CONFIG1H, _OSC_INTIO67_1H // internal oscillator, RA.6 and RA.7 as IO

#pragma DATA _CONFIG2L, _PWRT_ON_2L & _BOREN_OFF_2L

#pragma DATA _CONFIG2H, _WDT_OFF_2H

#pragma DATA _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H

 

void main(void)

{

// 4MHz internal oscillator

osccon = IRCF2 & IRCF1 & SCS1;

 

// all digital inputs

adcon1 = 0x0F;

 

// all pins as outputs

trisa = 0x00;

trisb = 0x00;

trisc = 0x00;

 

// all outputs off

porta = 0x00;

portb = 0x00;

portc = 0x00;

 

porta = 0x01;

porta = 0x02;

porta = 0x04;

porta = 0x08;

 

porta = 0x10;

porta = 0x20;

porta = 0x40;

porta = 0x80;

 

while(1) ;

}

 

The 18F2520 data sheet mentions a difference in the QFN versus PDIP package (RA.6 / RA.7 bidirectional or input or output),

but I have no way to choose this behaviour in SourceBoost.

 

Thanks,

 

Edward

Share this post


Link to post
Share on other sites

Hi

 

Your code looks good..

Except that if you run it freely you won't see nothing exceot the last output, 0x80. The values from 0x01 to 0x04 will be too fast to be seen.

 

Maybe its a simulation thing, have you tried with another one, maybe MPLAB SIMulator?

 

 

Best regards

Jorge

Share this post


Link to post
Share on other sites

Hi Jorge,

 

I checked with a small program in MPLAB, and that simulation works.

Building the hardware, and connecting some LED's confirms that RA.6 and RA.7 are normal outputs.

 

When simulating in SourceBoost, using the LCD-plugin on PortA/PortB works fine (except for RA.6/7).

Using PortC is a different story however. Seems that I have to report a bug on this combination.

 

Edward

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...