Help with PIC project


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2008
    Posts
    5

    Default Help with PIC project

    This is my first PIC Project and have enjoyed it so far but having trouble moving forward at the minute.

    I'm using MPLAB V8 and a PICstart programmer to burn the PIC, my clicking enable then program and it seens to work but then I got to test it on my breadboard I'm getting nothing out of the pins.


    Details:
    The PIC is been used for a prototype alarm system for toy car and hoping to then interface with PC to give a nice GUI and display which sensor was triggered.

    Code:

    list p=16f818 ; list directive to define processor
    #include ; processor specific variable definitions

    errorlevel -302 ; suppress message 302 from list file

    __CONFIG H'3F10'

    ;***** VARIABLE DEFINITIONS
    OPTION_R EQU 81H ;Option Register
    ZEROBIT EQU 2 ;means ZEROBIT is bit 2.
    COUNT EQU 20H ;COUNT a register to count events.
    COUNTA EQU 21H

    ;************************************************* *********************
    ORG 0x000 ; processor reset vector
    goto main ; go to beginning of program


    ; SUBROUTINE SECTION.

    DELAY MOVLW 0xFF ;load Decimal FF in W register
    MOVWF COUNT ;load Count with contents of W register
    LOADCA MOVLW 0xFF ;load Decimal FF in W register
    MOVWF COUNTA ;load CountA with contents of W register
    DEC DECFSZ COUNTA,F;decrement counterA and skip next line if Z=0
    GOTO DEC ;if countA not 0 than go to DEC
    DECFSZ COUNT,F ;decrement counter1 and skip next line if Z=0
    GOTO LOADCA ;if count1 not 0 than go to LOADC2
    RETURN ;else jump out of subroutine


    ;FLASH LEDS
    LED BSF PORTA,0 ;Turn on A0
    BSF PORTA,1 ;Turn on A1
    BSF PORTA,2 ;Turn on A2
    BSF PORTA,3 ;Turn on A3
    CALL DELAY
    BCF PORTA,0 ;Turn off A0
    BCF PORTA,1 ;Turn off A1
    BCF PORTA,2 ;Turn off A2
    BCF PORTA,3 ;Turn off A3
    RETURN

    ;FLASHING LEDS
    LEDs BSF PORTA,0 ;Turn on A0
    BSF PORTA,1 ;Turn on A1
    BSF PORTA,2 ;Turn on A2
    BSF PORTA,3 ;Turn on A3
    CALL DELAY
    BCF PORTA,0 ;Turn off A0
    BCF PORTA,1 ;Turn off A1
    BCF PORTA,2 ;Turn off A2
    BCF PORTA,3 ;Turn off A3
    CALL DELAY
    GOTO LEDs

    ;************************************************* *********
    ; CONFIGURATION SECTION.

    main BSF STATUS,5 ;change to bank1

    MOVLW B'11110000' ;Bits for mixed I/Os on portA
    MOVWF TRISA

    MOVLW B'00111011' ;Bits for mixed I/Os on portB
    MOVWF TRISB

    MOVLW B'00000000'
    MOVWF OSCCON ;oscillator 31.25kHz

    MOVLW B'00000111' ;prescaler is /256
    MOVWF OPTION_R ;TIMER is 1/32 secs

    BCF STATUS,5 ;return to bank0

    BSF SSPCON,5 ;Set bit 5 to high to enable RB1, RB2 as serial I/O ports

    CLRF PORTB ;clear portB register
    CLRF PORTA ;clear portA register
    CLRF COUNT ;clear count register
    CLRF COUNTA ;clear countA register

    ;************************************************* *********
    ;Program starts now.

    ARM BTFSC PORTA,4 ;INPUT FOR TRANSMITTER
    GOTO ALED
    GOTO ARM

    ALED CALL LED ;CALL LED SUBROUTINE
    GOTO POLLING


    POLLING BTFSS PORTB,0 ;CHECK ULTRASOUND
    GOTO ALARM
    BTFSS PORTB,1 ;CHECK DOOR 1
    GOTO ALARM
    BTFSS PORTB,5 ;CHECK DOOR 2
    GOTO ALARM
    BTFSS PORTB,4 ;CHECK TILT SWITCH
    GOTO ALARM
    GOTO POLLING

    ALARM BSF PORTB,6 ;TURN ON ALARM
    CALL LEDs ;FLASH LEDs
    BTFSC PORTA,4 ;WAIT FOR PORT TO BE LOW
    GOTO ALARM
    CLRF PORTA
    ;BCF PORTA,6 ;TURN OFF ALARM
    ;BCF PORTA,0 ;Turn off A0
    ;BCF PORTA,1 ;Turn off A1
    ;BCF PORTA,2 ;Turn off A2
    ;BCF PORTA,3 ;Turn off A3
    GOTO ARM


    ; initialize eeprom locations

    ORG 0x2100
    DE 0x00, 0x01, 0x02, 0x03


    END ; directive 'end of program'

    Thanks again

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    Here you are to speak PicBasic Pro ... asm ONLY if incuded into a PbP file ...

    Now,

    Think to include the right .inc file ( line 2 ) ... LOL !

    BUT, mostly ... think to disable the ADC Module and allow pins as DIGITAL !!!

    and check if SSP doesn't catch some Port pins ... ( you talk about a link to a PC ... so is it to disable ??? )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    MOVLW B'00000000'
    MOVWF OSCCON ;oscillator 31.25kHz

    That's pretty slow

    Now if you want to communicate with your PC, and make things easier, choose a PIC with a built-in USART. The MSSP module is not going to help you for that.

    I know i saw that somewhere else yesterday... not sure where.. but i saw that yesterday...
    <hr>
    EDIT ahhhhhh...
    http://www.picbasic.co.uk/forum/showthread.php?t=8565
    Last edited by mister_e; - 17th April 2008 at 17:25.
    Steve

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

  4. #4
    Join Date
    Apr 2008
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Yea steve your correct that was me yesterday also.

    Sorry I know this is PICBASIC only but found a lot of good stuff on these forums, just say I forgot about the PC interaction side of things, does my code look ok?

    I have include 16F818 on my main code don't know why I left it out.

    Thanks again.

Similar Threads

  1. Midi, Interrupts and Pic better than SX28?
    By Lajko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th September 2008, 00:26
  2. [Final Project Hurdle] Help with PIC programming.
    By mekohler in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 25th September 2007, 06:39
  3. Help on coding/ selecting PIC chip for project
    By lovemeok in forum General
    Replies: 0
    Last Post: - 27th July 2006, 19:21
  4. pic project help
    By dizzy1 in forum General
    Replies: 2
    Last Post: - 5th February 2006, 18:30
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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