1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Coding a PIC help?

Discussion in 'Miscellaneous' started by Charvel, Sep 9, 2010.

  1. Charvel

    Charvel New Member

    Joined:
    Sep 7, 2010
    Messages:
    8
    Occupation:
    Student
    Location:
    Turkey
    Balance:
    2Coins
    Ratings:
    +0 / 0 / -0
    Hello.

    I'm trying to writing code for my gauges. I'll drive 7 seg led for gear indicator.I'm using MPLAB assembly and 16F877A.I thought a simple test program like this:

    PC send data for 7. gear
    PIC reads data and compares with given code (11111111)
    Then if it's the same data it turn on led 1, turn off led2
    PC send data for R gear
    PIC reads data and compares with given code (00000000)
    Then if it's the same data it turn on led 2, turn off led1


    Here is my code.

    Code:
    
      list p=16F877A
      include p16F877A.inc
      __config H'3F3A'
    
      alinan equ 0x20
      test equ 0x21
      org 0
      clrf PCLATH
      goto main
    
    interrupt
    
      retfie
    
    Hazirlik
    
      banksel TRISC 
      bsf TRISC, 7
      movlw 0x81
      
      movwf SPBRG
      movlw 0x26
      movwf TXSTA
    
      movlw 0x90
      bcf STATUS, RP0
      movwf RCSTA
    
      bsf STATUS, RP0
      bsf PIE1, RCIE
      bsf INTCON, PEIE
      return
    
    karakter_al
      
      banksel PIR1
      btfss PIR1, RCIF
      goto $ - 1
      bcf PIR1, RCIF
      movf RCREG, W
      return
    
    main
     
      call Hazirlik
      bcf INTCON, GIE
    
    dongu
    
      call karakter_al
      movwf alinan
      
      movlw b'00000000'
      subwf test,w
      btfsc STATUS,Z
      goto gear_r
    
      movlw b'11111111'
      subwf test,w
      btfsc STATUS,Z
      goto gear_7
    
      goto dongu
      
      gear_r
      bsf PORTB,1
      bcf PORTB,2
      goto dongu
    
      gear_7
      bcf PORTB,1
      bsf PORTB,2
      goto dongu
    
    
    end
    
    If you can guide me i'll be very glad :)
  2. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    You are in the wrong forum. :D

    I don't think many of us are familiar with programming PIC's in assembly.
  3. Charvel

    Charvel New Member

    Joined:
    Sep 7, 2010
    Messages:
    8
    Occupation:
    Student
    Location:
    Turkey
    Balance:
    2Coins
    Ratings:
    +0 / 0 / -0
    What language are you using? Basic or C ? :)
  4. Frakk

    Frakk Active Member

    Joined:
    Apr 15, 2009
    Messages:
    1,144
    Balance:
    328Coins
    Ratings:
    +4 / 0 / -0
    I program AVR's in C.
  5. willynovi

    willynovi Member

    Joined:
    Feb 13, 2009
    Messages:
    64
    Location:
    Argentina
    Balance:
    354Coins
    Ratings:
    +2 / 0 / -0
    you are right Frakk,
    Charvel, I think you should visit Microchip´s Forum for help.

    regards, Willy
  6. Charvel

    Charvel New Member

    Joined:
    Sep 7, 2010
    Messages:
    8
    Occupation:
    Student
    Location:
    Turkey
    Balance:
    2Coins
    Ratings:
    +0 / 0 / -0
    I'll try Microchip's website and i want to learn C.If you got an example code in C language it will be very helpful.

    Thank you for your help :)
  7. sdecorme

    sdecorme New Member

    Joined:
    Aug 24, 2010
    Messages:
    31
    Occupation:
    Devellopper
    Location:
    Pierrelatte
    Balance:
    372Coins
    Ratings:
    +0 / 0 / -0
    How do you communicate between your PIC and your PC : USB, 232,ethernet.
    You can find some free compiler for PIC C or basic . You should take a 18F or 30F series , they have efficient bootloader
  8. tadythefish

    tadythefish Active Member

    Joined:
    Jul 8, 2009
    Messages:
    148
    Occupation:
    Process automation engineer
    Location:
    Slovenia
    Balance:
    676Coins
    Ratings:
    +95 / 1 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    isn't an arduino simpler to use?
    • Agree Agree x 1
  9. narthur157

    narthur157 Member

    Joined:
    Mar 8, 2015
    Messages:
    31
    Balance:
    258Coins
    Ratings:
    +31 / 0 / -0
    I'd seriously consider using C. Assembly isn't something you should do to yourself if you don't have to