18f2550 and PortE

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
madru
Posts: 10
Joined: Thu Oct 22, 2009 9:07 pm

18f2550 and PortE

Post by madru » Tue Oct 27, 2009 11:40 am

Hi,

how can I use RE3 as an input, looking though the definitions:

Code: Select all

public system port
   PORTC as byte absolute $0F82,
   PORTB as byte absolute $0F81,
   PORTA as byte absolute $0F80
PORTE is missing, should it not be

Code: Select all

public system port
   PORTE as byte absolute $0F84, //only RE3 can be used
   PORTC as byte absolute $0F82,
   PORTB as byte absolute $0F81,
   PORTA as byte absolute $0F80


or is there a different way to use RE3?
M

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Post by RKP » Tue Oct 27, 2009 12:45 pm

madru,

Try adding (Config MCLRE = OFF) to your source code.

Not sure if you need to modify the 18F2550.bas file.

madru
Posts: 10
Joined: Thu Oct 22, 2009 9:07 pm

Post by madru » Tue Oct 27, 2009 7:07 pm

....tried that already, also modifying the 18f2550.bas file doesn't help....

declaring the following in Swordfish

Code: Select all

   PORTE as byte absolute $0F84, //only RE3 can be used
   PORTC as byte absolute $0F82,
   PORTB as byte absolute $0F81,
   PORTA as byte absolute $0F80 
will end up in

Code: Select all

; SYSTEM PORTS...
PORTC            EQU 0X0F82
PORTB            EQU 0X0F81
PORTA            EQU 0X0F80
I guess the reason is the missing PORTD ?!

any help is appreciated :D
M

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Post by RKP » Wed Oct 28, 2009 12:17 am

madru,

Try adding this in the P18F2550.inc

Code: Select all

; SYSTEM PORTS... 
PORTE            EQU 0X0F84   ; Add this
PORTC            EQU 0X0F82 
PORTB            EQU 0X0F81 
PORTA            EQU 0X0F80
There is no PORTD in this PIC so it is not needed.
If this is no help, could you post some code?

RKP

madru
Posts: 10
Joined: Thu Oct 22, 2009 9:07 pm

Post by madru » Wed Oct 28, 2009 9:48 pm

Hi RKP,

changing the 18f2550.bas and 18f2550.inc will get rid of the compiler errors but RE3 doesn't work correctly, the ASM looks OK (I guess)

BTFSS PORTE,3,0 and BSF TRISE,3,0 the only little thing is the comment in the datasheet:

The fourth pin of PORTE (MCLR/VPP/RE3) is an input
only pin. Its operation is controlled by the MCLRE
configuration bit. When selected as a port pin
(MCLRE = 0), it functions as a digital input only pin; as
such, it does not have TRIS or LAT bits associated with
its operation.


I am lost, Profession help is needed :D

M

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Post by RKP » Thu Oct 29, 2009 2:12 pm

madru,

Here is a program written for the 18F2455 it is the little brother of the 18F2550 (I do not have a 18F2550).

Anyway here is the program and it works.

Code: Select all

{
*****************************************************************************
*  Name    : Test_RE3.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 10/29/2009                                                     *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}
Device = 18F2455
'Device = 18F2550
Clock = 8

Config  MCLRE = OFF,    ' *** This is needed to make PORTE bit3 an input. ***         
        FOSC = HS       ' External 8MHz crystal
                    

Dim LED As PORTB.0      ' Led on PORTB bit 0


TRISA = $00             ' Make PORTA all outputs
TRISB = $00             ' Make PORTB all outputs
TRISC = $00             ' Make PORTC all outputs

LATA = $00              ' Make PORTA outputs Low
LATB = $00              ' Make PORTB outputs Low
LATC = $00              ' Make PORTC outputs Low

' All this loop does is test PORTE.3 and make the LED on PORTB bit 0 ON
' if PORTE.3 is HIGH or OFF if PORTE.3 is LOW
While true
    If PORTE.3 = 1 Then LED = 1
        Else LED = 0
    EndIf
Wend
Here are the changes I made in the P18F2550.inc and P18F2455.inc

Code: Select all

; SYSTEM PORTS... 
PORTE            EQU 0X0F84   ; Add this 
PORTC            EQU 0X0F82 
PORTB            EQU 0X0F81 
PORTA            EQU 0X0F80 
Also changes in the P18F2550.bas and P18F2455.bas

Code: Select all

// system ports...
Public System Port
   PORTE As Byte Absolute $0F84,  ' added this 
   PORTC As Byte Absolute $0F82,
   PORTB As Byte Absolute $0F81,
   PORTA As Byte Absolute $0F80
This works just fine on my EasyPic4 board.

RKP

madru
Posts: 10
Joined: Thu Oct 22, 2009 9:07 pm

Post by madru » Thu Oct 29, 2009 8:18 pm

Hi RKP,

THX for all your help, my modifications of the inc and bas file are the same (obviously)......

anyway I have it working now BUT not on my EasyPIC5 board, the RE3 ends up somewhere in the on-board programmer :?
......I removed pin 1 from the board ,added a 10K pullup and I am a happy bunny now :)

THX again

M

Post Reply