Pic16f88


Closed Thread
Results 1 to 6 of 6

Thread: Pic16f88

  1. #1
    Join Date
    Nov 2007
    Posts
    4

    Default Pic16f88

    Dear experts,

    I am new to this programing. I have a small project which i would like to get help with. Its a small car which should turn ON the lights and turn OFF with two buttons.

    Please help me.

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    Hi and welcome.

    try the following
    Code:
            '
            '       Pic Configuration
            '       =================
            ASM
            IFNDEF PM_USED
                list w=-207
                ;    Program Configuration Register 1
                cfg1 = _INTRC_IO & _WDT_OFF & _PWRTE_ON & _MCLR_OFF & _BODEN_ON & _LVP_OFF & _CCP1_RB0
                cfg2 = _CP_OFF  & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF 
                __CONFIG    _CONFIG1, cfg1 & cfg2		    		 
                
                ;    Program Configuration Register 2
                __CONFIG    _CONFIG2, _IESO_OFF & _FCMEN_OFF
                list w=+207
                ELSE
                    device  INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_ON, MCLR_OFF, BOD_ON, LVP_OFF, CCPMX_OFF 
                    device  PROTECT_OFF, CPD_OFF, WRT_OFF, DEBUG_OFF    
                    device2 FCMEN_OFF, IESO_OFF
                ENDIF
            ENDASM
            OSCCON = %01100000 ' set to 4 MHz clock
            
            '
            '       Hardware configuration
            '       ======================
            TRISB=0     ' Set all PORTB pins to output
            TRISA=255   ' Set all PORTA pins to output
            ANSEL = 0   ' disable adc converters
            CMCON=7     ' disable analog comparator
            
            '
            '       Hardware assignment
            '       ===================
                    '       
                    '       Push buttons
                    '       ------------
                    '       Push buttons are connected between PIC i/o and gnd
                    '       don't forget to add a pull-up resistor on the i/o too
                    '
            ONButton    VAR PORTA.0
            OFFButton   VAR PORTA.1
                    '
                    '       Light
                    '       -----
                    '       LED connect between I/O and gnd... with a resistor in serie
                    '
            LIGHT       VAR PORTB.0
    
            '
            '       Hardware initialisation
            '       =======================
            WHILE OSCCON.2=0 : WEND     ' wait 'till internal OSC is stable
            PORTB=0                     ' clear all PORTB i/o 
            
    START:
            if ONButton = 0 then
                light = 1   ' turn the LED on
                endif
    
            if offbutton = 0 then
                light = 0   ' turn the led off
                endif           
                
            GOTO START
    Steve

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

  3. #3
    Join Date
    Nov 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    thanks a lot, question! the above configs. can be done in the software as well right so i dont need to do those in the coding??

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


    Did you find this post helpful? Yes | No

    Default

    yes you can do it in your programmer software as well... but you need to set them each time... and remind which one you need to set. Kinda annoying if months/years later you need to reprogram a PIC and you don't remind them.

    Once you load the .HEX file to program your PIC, your PIC Programmer software have to be smart enough to refresh the default one and to program them. Careful, some software need to be warned to do so.

    I ALWAYS set them in code, it's the right place to fit them.. not in a README.TXT or on a piece of paper sticked somewhere.

    But it's me

    EDIT: the above are way to much, but as i didn't know which assembler you're using (PM/MPASM) i've just put both and let the compiler choose for you. See the FAQ for more details.
    Last edited by mister_e; - 18th November 2007 at 11:08.
    Steve

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

  5. #5
    Join Date
    Nov 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    thanks a lot, I will try it out and let you know. another thing forgot to ask. will it work for 4 LEDs or two? e.g. two front two rear...

  6. #6
    Join Date
    Nov 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    .....................
    Last edited by nonny; - 20th November 2007 at 14:15.

Similar Threads

  1. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 00:13
  2. pic16f88 & voltage
    By rdxbam in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th February 2009, 09:14
  3. Ghange code from PIC16F877A to PIC16F88
    By savnik in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th March 2008, 16:09
  4. Replies: 8
    Last Post: - 7th December 2006, 15:42
  5. PIC16F88 problem with TOGGLE command?
    By russman613 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th September 2006, 23:31

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