PIC programming (assembly code) help

Discussion in 'General Electronics Chat' started by bluebrakes, Jul 27, 2011.

  1. bluebrakes

    Thread Starter Active Member

    Oct 17, 2009
    245
    7
    Hi,

    Long time no see. :)

    I'm working on a RS232 serial controller for my project. Basically turns on and off the pic outputs based on commands from the computer.

    What I need help with is writing code that does an IF statement based on the character in the register.

    So basically if I send an 'F' over the serial line, I want RB0 to turn on.

    I'm not sure how to do the IF command in assembly code to compare a character against the register of the 16f628a pic.

    I've managed to get my code to turn on LEDs, etc with just bashing any old key, but I need to be able to go the next stage.

    Any ideas?
     
  2. bluebrakes

    Thread Starter Active Member

    Oct 17, 2009
    245
    7
    i think this is the closest i've got with the code...

    ; So if the character in the register is character 0 then call step1
    MOVLW 0h ; Check Reset Command
    SUBWF TXREG, w
    BTFSC STATUS, Z ; Does it match?
    CALL step1 ; Yes
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,606
    Well... first off, wrong forum. Mods may move this.

    A Capital "F" is a hex 0x46, lower case is 0x66. You need to monitor your data stream over the RS232, look for a match to that character, and if true then you'd just bsf PORTB, 0

    Otherwise I can't suggest anything as I am bad at imagining source code.
     
  4. bluebrakes

    Thread Starter Active Member

    Oct 17, 2009
    245
    7
    somehow i've cracked but the worst thing is i don't know why.... grrr!!!
    the worst kind. thanks anyway.

    The next problem is the pic code crashes or something when too much data is sent at once. It just stops responding to the commands.... hmmm.
     
Loading...