TTL input - 3rd states possible?


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    Okay; finally, it works.

    Here is my code I had to correct according to Sougata's example.

    Code:
    ' Fuses
    @ DEVICE PIC16F88,INTRC_OSC_NOCLKOUT
    @ DEVICE PIC16F88,PROTECT_OFF
    @ DEVICE PIC16F88,WDT_OFF
    @ DEVICE PIC16F88,PWRT_ON
    @ DEVICE PIC16F88,MCLR_ON
    @ DEVICE PIC16F88,BOD_OFF
    @ DEVICE PIC16F88,LVP_OFF
    @ DEVICE PIC16F88,CPD_OFF
    @ DEVICE PIC16F88,DEBUG_OFF
    @ DEVICE PIC16F88,CCPMX_OFF
    
    '-------------------------------------------------------------------------------
    ' Registers   76543210
    OSCCON     = %01100000  '4MHz
    OPTION_REG = %10000000  'D I S A B L E PORTB's Pull-Ups for buttons
    'ANSEL      = %00000000  'Disable Analogue Inputs
    TRISA      = %00000000  'Inputs/Outputs
    TRISB      = %00100000  'Inputs/Outputs
    
    '-------------------------------------------------------------------------------
    ' Variables
    Led0  var PORTA.0
    Led1  var PORTA.1
    HiLow var PORTB.5   'this port is TTL only
    InOut var TRISB.5
    Time  var byte
    time  = 2
    
    '-------------------------------------------------------------------------------
    ' Program
    MAIN:
        inout = 0
        hilow = 0
        pause time
        inout = 1
        pause time
        if hilow = 1 then led1 = 1 : goto main
        led1  = 0
        inout = 0
        hilow = 1
        pause time
        inout = 1
        if hilow = 0 then led0 = 1 : goto main
        led0 = 0
        Goto MAIN
        end
    ANSEL or not, it works.

    I changed the 0,1µF cap for a 0,01µF and reduced the pause time to 2 so it goes drastically faster.

    Thanks a lot for your patience.

    In fact, I was stuck in my mind thinking this problem would have to be resolved another way than by a software routine...
    Roger

  2. #2
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Thumbs up Great

    Thanks mister_e, I just read your post.

    I removed the cap and PAUSEs.

    It works too very well.

    Cool
    Roger

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


    Did you find this post helpful? Yes | No

    Default

    use a ADC input....

    EDIT: just read yours... WOOOHOOO! good luck!
    Steve

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

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Asm?

    mister_e,

    May I ask you what this BASIC routine would have become in assembly?

    Please, don't waste your time if it is long to do.

    I'm just curious to compare what "I know" (=BASIC) to what I don't (=ASM).

    I don't really understand the difference between BASIC and ASSEMBLY in terms of program execution speed (looks to be faster in ASM but I don't understand why - have to find other threads for more info) because I never looked into it up to now - looks very complicated.
    Roger

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I used to worry about how tightly BASIC compiles down to actual assembly. I don't anymore. If you look at PBP source code relatively close, you'll see that most of the PBP commands directly relate to straight assembly programming, while others may take 1-2-3 ASM instructions to complete a PBP instruction. Again...I used to worry about it. There's only a few instances where straight assembly can make anything faster. If you really want to see it, take a look at your .LST file generated during assembly. Put a couple of labels around the code you're interested in and do a search of the file.

Similar Threads

  1. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 18:51
  2. RB0 + Internal Pullup + Interrupt
    By Freman in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 10th August 2009, 11:11
  3. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 20:31
  4. 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
  5. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19

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