Menu

My fist chip project:- writting things up

ldean
2009-11-18
2013-05-30
  • ldean

    ldean - 2009-11-18

    I have a Pic16f684 a 14 pin pic
    1 MHz speed
    I'm wanting 2 analog inputs
    the rest led drivers
    and timer 0
    I want to use the interprat for the A/D for stablity

    But I can not complile
    why not>
    I have my code on the great cow basic directroy and its fownd the *.dat file ok

    my code so far

    #chip 16F684, 1

    #Config NOT_RAPU = off, TOCS = off, PSA = off, PS2 = on, PS1 = on, PS0 = on

    #OPTION   '11010011'  //T0SE = 0N, PSA = OFF, PRESCALER 1/16TH
    #INTCON = '00100000'    // sets up timer 0 overflow
    #PIE1 =   '01000000'
    #PIR1 =   '01000000'
    #PCON =   '00110000'
    #osccon = '01000101'   // = 1 MEG INTERNIL OSC
             //IRCF0 = 4, OSTS = 0ff, HTS = on, LTS = off, SCS = on

    #TRISA =  '00110100'
    #IOCA =   '00000000'
    #TRISC =  '11111111'

    //#ADCON0 ADON = ON  //  =  START ADC
    #ADCON0 = '00000001'
    #ADCON1 = '00000000'   // = FOSC 2 SET FROM INTERNIL OSC
    #ANSEL  = '00000011' // SET PIN 12-13 TO ANALOG IN

    main

    Goto Main

    Lex Dean

     
  • Nobody/Anonymous

    How about starting with a simple blinky led program first, then expand from there.  There are many good example programs offered in the HELP file, found either on the GCBasic web page, or in the GCBasic folder.  Doing a few examples will help you get accustomed to the required GCBasic syntax.

    While you can easily set individual PIC internal registers, it is not often required.  For instance, instead of writing the TrisX register, use the dir PortX.x out/in command.

    Also, unless there is a special reason, setting the internal oscillator to a higher setting like 4Mhz (or better yet, 8Mhz and up if available).  Some program libraries are just not going to run well, if at all with a slow clock.

    Try the blinky led, a-d, timer, and interrupts individually first.  Then add them together, It will be much easier to debug your program that way.

        #chip 16f684, 8
        #config INTRC_OSC
       
        #define LED1 PortC.0
        #define LED2 PortC.1
        dir LED1 out
        dir LED2 out
       
        Main:
        SET LED1 ON
        SET LED2 OFF
        WAIT 50 10ms
        SET LED1 OFF
        SET LED2 ON
        WAIT 50 10ms
        goto Main

     
  • Nobody/Anonymous

    I need to ran to use the complier!!!!!!!!!!!

    The complier is vague in error messages and many programs seen half complete.

    I have questions over selecting the correct chip

    And understanding the error messages.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.