How to set external clock source in PBP


Results 1 to 29 of 29

Threaded View

  1. #1
    TurboLS's Avatar
    TurboLS Guest

    Default How to set external clock source in PBP

    I am trying to use an external resonator with my circuit and I was wondering what i set

    DEFINE ADC_CLOCK to to use an external 20mhz resonator.

    I already set OSC to 20, but that doesn't seem to work. Also, how do I set an 8 bit data word acquired from an analog in, to output bit by bit, say through the entire PORTB. I was going to wire it up to 8 LEDs to make sure it was working and I can't find any documentation on how to set an entire port to output an 8 bit digital word. My code is as follows:

    ' PicBasic Pro program to perform
    ' 8-bit A/D conversion
    '
    ' Connect analog input to (RA0)
    ' Connect LEDs to 8 pins of PORTB

    include "modedefs.bas"

    ' Define ADCIN parameters
    Define ADC_BITS 8 ' Set number of bits in result
    DEFINE OSC 20 ' Sets clock speed to 20Mhz
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    adval var byte ' Create adval to store result

    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00000010 ' Set PORTA analog
    TRISB = %00000000 ' Set PORTB to all output
    Pause 500 ' Wait .5 second

    SHIFTOUT PORTB,PORTA.7,0,[adval] ' Output 8 bit word to PORTB
    Pause 500 ' Wait .5 second

    ' Do A/D conversion after each pixel shift

    loop: ADCIN 0, adval ' Read channel 0 to adval
    Goto loop ' Do it forever
    End
    Last edited by TurboLS; - 16th February 2005 at 21:46.

Similar Threads

  1. HW PWM not working
    By comwarrior in forum General
    Replies: 5
    Last Post: - 31st July 2009, 17:16
  2. Microcode studio - PIC16F877A Interrupts
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th January 2009, 06:10
  3. Data Out From External Clock
    By Quin in forum Serial
    Replies: 2
    Last Post: - 25th October 2008, 09:11
  4. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 22:06
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

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