problem with input and output (18F452)


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Location
    Ankara -Turkey
    Posts
    27

    Default problem with input and output (18F452)

    I use 18F452 4MGz xt.some of the codes are below.
    I use PORTA ,PORTC and PORTE output.INPUT PORTD.3 INPUT PORTC.6 INPUT PORTC.4
    LCD and keypad working nice but INPUT and OUTPUT ports not working.
    Is there anybody to help me .
    Thanks.

    INCLUDE "KeyPad.bas"

    ---------------------------------
    ---------------------------------

    'Define LCD connections
    Define LCD_DREG PORTD
    Define LCD_DBIT 4
    Define LCD_RSREG PORTD
    Define LCD_RSBIT 0
    Define LCD_EREG PORTD
    Define LCD_EBIT 1
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 4
    DEFINE LCD_RWREG PORTE
    DEFINE LCD_RWBIT 2
    'Define keypad connections
    DEFINE KEYPAD_ROW 4 ' 4 ROW keypad Tuştakımı yatay
    DEFINE KEYPAD_ROW_PORT PORTB ' ROW port = PORTB
    DEFINE KEYPAD_ROW_BIT 4 ' ROW0 = PORTB.4
    DEFINE KEYPAD_COL 4 ' 4 COL keypad Tuştakımı kolon
    DEFINE KEYPAD_COL_PORT PORTB ' COL port = PORTB
    DEFINE KEYPAD_COL_BIT 0 ' COL0 = PORTB.0
    DEFINE KEYPAD_DEBOUNCEMS 100 ' debounce delay = 20 mSec
    DEFINE KEYPAD_AUTOREPEAT 1 ' use auto-repeat feature
    ' Define program variables
    tus var byte ' tus değeri
    sayim VAR word
    ma VAR word
    nm VAR word
    hy VAR word
    sy150 VAR word
    sy40 VAR word
    tyag VAR word
    thacim VAR word

    INTCON2.7 = 0 ' Enable PORTB pullups (18F452)
    ADCON1 = 7 ' PORTA PORTE digital
    TRISC = %00000000
    TRISE.0 = 0
    TRISE.1 = 0
    TRISE.2 = 0
    LOW PORTE.0
    LOW PORTE.1
    LOW PORTE.2' LCD R/W low (write)
    LOW PORTC.0
    LOW PORTC.1
    LOW PORTC.2
    LOW PORTC.3
    LOW PORTC.5
    LOW PORTC.7
    LOW PORTA.0
    LOW PORTA.1
    LOW PORTA.2
    LOW PORTA.3
    LOW PORTA.4
    LOW PORTA.5
    INPUT PORTD.3 'TEMAS TUŞU
    INPUT PORTC.6
    INPUT PORTC.4 ' SİNYAL GİRİŞİ
    Pause 200 ' LCD açılması için bekle

    ---------------
    --------------
    ........
    Thanks
    Birbirimize yardım için buradayız.
    We are here to help each other....

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Parallel Port setup is wrong perhaps

    Quote Originally Posted by turkuaz View Post

    TRISE.0 = 0
    TRISE.1 = 0
    TRISE.2 = 0
    Use instead
    Code:
    TRSIE = 0
    PIC18F452 has a parallel port (PMP) similar to a microprocessor bus which uses the TRISE register for the configuration and the PORTE as the control line for the PORTD (PMP) read write. Other bits (7 to 4) are used to configure this.

    Hope this helps
    Regards

    Sougata

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    TrisD = %00001000 ' all port d as outputs except bit 3 input
    TrisC = %01010000 ' all port c outputs except bits 6 and 4 inputs
    TrisA = %00000000 ' all port a as outputs
    TrisB = %11110000 ' lower 4 bits outputs upper inputs
    TrisE = %00000000 ' all 8 bits as outputs
    edit: Sougata undoubtly knows what he is talking about and posted while I was writing.
    Last edited by Archangel; - 17th March 2008 at 16:28.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Jun 2007
    Location
    Sydney, Australia
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    And make sure that all your DEFINE statements are in upper case, ie:

    Define LCD_DREG PORTD

    should be

    DEFINE LCD_DREG PORTD

    (Skimask & Bruce pointed this out to me last week!)

    Phil.

Similar Threads

  1. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 20:31
  2. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  3. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  4. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

Members who have read this thread : 1

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