3-to-8 Decoder Program


Closed Thread
Results 1 to 3 of 3
  1. #1
    BlackNoir's Avatar
    BlackNoir Guest

    Default 3-to-8 Decoder Program

    Hi, I'm trying out different things with PICBasic Pro and one of the programs I'm trying to write is a 3-to-8 Decoder. The problem I'm having is with the inputs on PortA. No matter what I do, I can't get them to work. I'm using a 16F628A PIC with a 5V+ fed through a 10k resistor to make my input high. If I use some of PortB as Input, those work, it's just PortA I can't seem to use.

    Heres the start of my program. It doesn't actually decode yet, I'll finish that once I get these dang Inputs to work.

    Thanks,
    BlackNoir



    '3-to-8 Decoder

    'Initialize variables needed in program
    B2 VAR BYTE

    'Initialize Port(s)
    TRISB = 0 'set port B pins as output (00000000)
    TRISA = %00000111


    Loop1:


    B2 = 0

    IF PORTA.0 = 1 Then
    B2 = B2 + 1
    EndIF

    IF PORTA.1 = 1 Then
    B2 = B2 + 2
    EndIF

    IF PORTA.2 = 1 Then
    B2 = B2 + 4
    EndIF

    PORTB = B2

    GoTo Loop1

  2. #2
    Join Date
    Apr 2005
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Porta is normally set to comparator.
    Use this:

    CMCON=$07 'NO comparator on PORTA

    and pins become bidirectional.
    Read carefully the datasheet and how to set mclr pin.

    bye
    roberto

  3. #3
    BlackNoir's Avatar
    BlackNoir Guest


    Did you find this post helpful? Yes | No

    Default

    That did it! Thanks roberto!!

Similar Threads

  1. CTCSS Tone Decoder Sample Program
    By sozkarabacak in forum General
    Replies: 0
    Last Post: - 20th October 2009, 06:15
  2. Replies: 4
    Last Post: - 15th April 2009, 01:54
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. Someone help me to simplify this
    By thrix in forum General
    Replies: 4
    Last Post: - 21st February 2004, 05:01
  5. Help wanted..
    By thrix in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 17th February 2004, 23:44

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