PortE problems (PIC18F4455)


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Posts
    15

    Default PortE problems (PIC18F4455)

    Hi there,

    If got a little problem (but strange to me). I'm trying to use portE of my pic18F4455. Now i'm using it as an input, but later I also want to use it as an output.

    The problem is that only pin RE3 look to work fine.

    Here the code I'm using:
    Code:
            Include "modedefs.bas" 
            
            DEFINE OSC 4
            E_0         VAR     WORD
            E_1         VAR     WORD
            E_2         VAR     WORD
            E_3         VAR     WORD
            TestLED     VAR     PORTC.6
            RS232TX     VAR     PORTD.2
           
    Intro:
        ADCON0 = 7
        ADCON1 = 7
        ADCON2 = 7
        CMCON  = 7
        TRISC  = 255
        
        HIGH TestLED
        Pause 100
        LOW TestLED
        PAUSE 100
        HIGH TestLED
        Pause 100
        LOW TestLED
        
        SEROUT RS232TX,N9600, ["Start...",13,10]
        GOTO Main
        
    Main:
          E_0 = PORTe.0
          E_1 = PORTe.1
          E_2 = PORTe.2
          E_3 = PORTe.3
          SEROUT RS232TX,N9600, ["E0=", #E_0, " E1=", #E_1, " E2=", #E_2, " E3=", #E_3 ,13,10]
          Pause 200
    
    GOTO Main

    In the serial output only the RE3-value changes from 1 to 0, when I switch the pin from high to low

    Output:

    E0=0 E1=0 E2=0 E3=1
    E0=0 E1=0 E2=0 E3=0

    What am I doing wrong?

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    adcon1=$0F
    is one of the setting that will work...

    datasheet ....
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Mar 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Thanks, I thought I'd tried everyting, but it works fine now.

  4. #4
    Join Date
    Mar 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Now I would like to disable the USB-controller of this pic, because I don't need this feature and I have to use the input pins RC4 and RC5.
    I've read the datasheet and I can disable USB by setting bit3 (USBEN) of the UCON register to zero. The problem is that it looks that PBP doesn't know the commands I want to use. I think i have to use assembly. I tried the following, but I get a warning.

    Code:
    ASM
    MOVLW 0h
    MOVWF UCON
    ENDASM
    Warning:
    Found opcode in collumn 1. (MOVLW)
    Found opcode in collumn 1. (MOVWF)

    I think my assembly knowledge is very bad
    Attached Images Attached Images  

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Reason is that there's no UCON register definition in the PIC18EXT.bas file

    look at the end and add it like this
    Code:
    TXREG2	VAR	BYTE EXT
    TXSTA	VAR	BYTE EXT
    TXSTA1	VAR	BYTE EXT
    TXSTA2	VAR	BYTE EXT
    UCON    VAR	BYTE EXT <= here
    VELRH	VAR	BYTE EXT
    VELRL	VAR	BYTE EXT
    WDTCON	VAR	BYTE EXT
    WREG	VAR	BYTE EXT
    hey!!! don't place the comment to the right
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,

    I also need to add UCON and UCFG for a PIC 18F4550. Adding the variables in the file mentionned above corrects the undefined error at compile time, but how do those variables get linked with the proper registers?

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. LCD Problems
    By gtx15 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th September 2007, 03:04
  2. New to PBP and having problems!
    By Lauren Barta in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th October 2006, 03:49
  3. 18F6680 and portd problems.
    By jkbh in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 6th June 2005, 10:54
  4. HSEROUT Problems
    By SergioRM in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th April 2005, 23:17
  5. Display problems
    By rossfree in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th November 2004, 23:36

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts