Help with Count PORTB.0


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Location
    Puerto Rico
    Posts
    133

    Exclamation Help with Count PORTB.0

    I need to find a circuit to made pulse to test the Count PORTB.0 to see if is reading correct ..

    thanks for any help.
    My Hobbies is PicBasic PRO

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Use another PIC and FREQOUT.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2005
    Location
    Puerto Rico
    Posts
    133


    Did you find this post helpful? Yes | No

    Thumbs up

    thanks for help
    My Hobbies is PicBasic PRO

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Or use the same PIC with hardware PWM. This can output the pulse in the background
    while COUNT works in the foreground.

    Or use Timer1 in counter mode, and just loop through setting/clearing a pin connected to
    the counter input.
    Code:
        DEFINE OSC 20 ' tested using a 16F877A on LAB-X1
        
        DEFINE HSER_CLROERR 1 'Automatically clear any USART overflows.
        DEFINE HSER_RCSTA 90h 'Set receive register to receiver enabled
        DEFINE HSER_TXSTA 24h 'Set transmit register to transmitter enabled
        DEFINE HSER_BAUD 9600 'Set baud rate
        Tmr1Val VAR WORD
        Loops   VAR WORD
        NumLoops VAR WORD
        INTCON  = 0           'Global interrupts disabled (peripheral interrupts disabled)
        ADCON1  = 7           'All digital
        TRISA   = %00010000
        TRISB   = %01010001
        TRISC.0=1              'Timer1 clock input connected to RA0
    
        ' Default idle logic on Timer1 counter input is logic 1
        HIGH PORTA.0
        TMR1L=0 : TMR1H=0
        T1CON = %00000011
        PAUSE 50
        HSEROUT ["Begin",13,10]
    
    Start:           
        ' Generate a random number  
        RANDOM NumLoops
        
        ' Output random number of low-to-high pulses for
        ' Timer1 counter input
        FOR Loops = 1 TO NumLoops
           LOW PORTA.0 
           HIGH PORTA.0
        NEXT Loops
        
        ' Read Timer1 count into word variable Tmr1Val
        Tmr1Val.LowByte = TMR1L
        Tmr1Val.HighByte = TMR1H
        
        ' Display count
        HSEROut [" Random # = ",DEC NumLoops," Count = ",DEC Tmr1Val,13,10]
        
        ' Clear Timer1 count before starting over
        TMR1L=0
        TMR1H=0
        goto start
       
        END
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  2. Can't get COUNT to count
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd March 2009, 23:14
  3. Multiplex Display with count comand
    By mdaweb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th October 2005, 04:09
  4. Count command
    By hawk72501 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th September 2005, 19:04
  5. count problem
    By servo260 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd December 2004, 15:05

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