16F913 setup


Closed Thread
Results 1 to 32 of 32

Thread: 16F913 setup

Hybrid View

  1. #1

    Default 16F913 setup

    I am new to the 16f913, can somebody help me with the hardware setup i want to use the first 4 pins on port a as analog inputs, the first 4 inputs on portb as digital inputs portb6 and 7 for the ICD2, the first 4 of port c as digital outputs and port c 6 and 7 for serial comunications.

    Do anyone have a way to do this setup fast on diferent micro's?

  2. #2


    Did you find this post helpful? Yes | No

    Default

    This is as far as i got, can somebody please help me with the errors mentioned below?

    DEFINE OSC 20 ' Define crystal as 20Mhz

    'This Part set PORTA 0-5 an analog inputs

    ADCON1 = %111 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
    ANSEL = 0 'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
    CMCON0= 0 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
    TRISA = %00011111 'set PORTA 0-5 as inputs


    TRISC = %10001111 'Set PORTC for serial coms and pins 0 - 3 as inputs
    TRISB = %00000000 'Sert PORTb as outputs and for use with the ICD2


    ERROR Line 13: Syntax error.
    ERROR: RAM END must be defined.
    ERROR: RAM BANKS must be defined.
    ERROR: No LIBRARY statement or LIBRARY parameter.
    ERROR: No LIBRARY statement or MACRO parameter.
    ERROR: Unable to open file PBPMAC.INC

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


    Did you find this post helpful? Yes | No

    Default

    no such error here. Which version of PBP are you using?
    Steve

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

  4. #4


    Did you find this post helpful? Yes | No

    Default

    MPLAB 8 and PBP 2.46, i also do not get the error with microstudio

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


    Did you find this post helpful? Yes | No

    Default

    mmm, sounds like a corrupted file, did you tried to re-install PBP and it's patch for 2.46?
    http://www.melabs.com/support/patches.htm
    Steve

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

  6. #6


    Did you find this post helpful? Yes | No

    Smile

    thanks, i created a totaly new project and copied my code into it, it seems to have fixed the problem it compiles now without problems.
    is there any thing you think i left out to have the pic do what i setted out to do in my first post?

  7. #7


    Did you find this post helpful? Yes | No

    Talking

    For those who are also trying this here is a working program reading the 5 analog channels on a 16F913 and sending it out on the serial port, hope this will help someone having a few less sleeples nights, thank you for everyone who helped me get this far

    INCLUDE "ANSI.INC"

    DEFINE OSC 20 ' Define crystal as 20Mhz

    '*Serial port Setup 9600 8N1*
    DEFINE HSER_BAUD 9600 ; 9600 Baud
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ; Clear overflow automatically

    '*ADC setup*
    DEFINE ADC_BITS 10 'SETS NUMBER OF BITS IN RESULTS 8,10,12
    DEFINE ADC_CLOCK 3 'SETS CLOCK SOURCE (RC = 3)
    DEFINE ADC_SAMPLEUS 50 'SETS SAMPLING TIME IN MICROSECONDS

    'This Part set PORTA 0-5 an analog inputs
    ADCON1 = %01110000 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
    ANSEL = %00011111 'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
    CMCON0 = %00000111 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
    TRISA = %00011111 'set PORTA 0-5 as inputs
    ADCON0.7 = 1 'Right justify output of ADC datasheet P145 of 16F913

    TRISC = %10001111 'Set PORTC for serial coms and pins 0 - 3 as inputs
    TRISB = %00000000 'Sert PORTb as outputs and for use with the ICD2

    INTCON = 0 ;Disable interrupts

    V1 var word
    V2 var word
    V3 var word
    V4 var word
    V5 var word


    loop:
    @ ClearScr ; Clear Screen
    ADCIN 0,V1
    ADCIN 1,V2
    ADCIN 2,V3
    ADCIN 3,V4
    ADCIN 4,V5
    HSEROUT ["Value of ADCIN 0 = ",dec V1,10,13]
    HSEROUT ["Value of ADCIN 1 = ",dec V2,10,13]
    HSEROUT ["Value of ADCIN 2 = ",dec V3,10,13]
    HSEROUT ["Value of ADCIN 3 = ",dec V4,10,13]
    HSEROUT ["Value of ADCIN 4 = ",dec V5,10,13]
    PAUSE 500
    goto loop

    END

Similar Threads

  1. ADCIN - setup of ADCON2
    By Lowell314 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 7th December 2009, 18:41
  2. TMR1 external LP xtal setup check
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th October 2009, 18:11
  3. ADCIN setup for PIC16F688
    By PixController in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th February 2008, 18:38
  4. ADCIN setup help need
    By dangill in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th February 2008, 15:22
  5. Use Button For setup
    By tump in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 21st November 2007, 19:43

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