16f873a issues, pbp beginner


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2011
    Posts
    2

    Default 16f873a issues, pbp beginner

    Hi everybody, I am a beginner in PBP, just started 2 weeks ago...
    am experiencing problems with porta.5 and 4 of 16f873a, i cant make them high, i dont know what could be the problem...
    also, I tried to insert some line of assembly codes using the asm...endasm instruction but the compiler returns an error "opcode expected instead of porta,portb.." if anybody knows what s happening, please help me

    thank you in advance

    ps: i am building a safe system with 3x4 keypad connected to portc, 3 7segment displays connected to portb , porta.0,1 and 2 switch between the displays and porta.4 and 5 are my output to buzzer and relay, this is the sample program i wrote to check my hardware , and i seem to dont get it right...and i still have to do the keypad interfacing...

    adcon1=6
    trisa=0
    trisb=0
    portb=%11111111
    porta.0=1
    porta.1=1
    porta.2=1
    porta.4=1
    porta.5=1
    sound porta.3,[100,5000]
    end
    'the program above worked except that i dint get any output from ra4 and ra5


    'there is the one that returned me errors
    adcon1=6
    trisa=0
    trisb=0
    asm
    movlw 0ffh
    movwf portb
    bsf porta,0
    bsf porta,1
    bsf porta,2
    bsf porta,5
    endasm
    sound porta,[100,50]
    end

    'thankyou

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: 16f873a issues, pbp beginner

    Hi,
    What's connected to PortA.4 and PortA.5?
    (EDIT: Sorry you did tell us that, I just didn't read it)
    I'm guessing the good old ReadModifyWrite problem. For a simple test insert a Pause 10 between each commad writing to PortA and see if it helps. It doesn't fully explain why PortA.5 doesn't go high but I guess it might depend on how the SOUND command works internally, try it and see if it helps.

    Usually problems like this are caused by some multiplexed function on the pins but I see that you HAVE turned the ADC off and the comparators (which have their outputs on RA4 and 5) SHOULD default to OFF. But just for the heck of it you could include CMCON=7

    I THINK that the other problem you're having might be that the assembler is CASE-sensitive. So instead of porta try PORTA, atleast your example compiles and assembles fine here with all capital letters in the register names.

    /Henrik.

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: 16f873a issues, pbp beginner

    Henrik,

    Apparently your PM is full!

    rgds,
    Hank.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: 16f873a issues, pbp beginner

    Thanks, it's fixed now.
    Sorry for the OT.

    /Henrik.

  5. #5
    Join Date
    Nov 2011
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: 16f873a issues, pbp beginner

    thanks guys....but i have tried to insert pause as you told me but still nothing...i moved the output line to the relay at porta.5 abd it seems to work now...but now, my portb is no longer holding values, it clears itself everytime i write on it...but when i comment out the line that writes on porta.5, it works perfectly..any clue???
    still cant compile when i insert the asm lines, even when using capitals letters...

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: 16f873a issues, pbp beginner

    Hi,
    Are you using MicroCode Studio as your IDE?
    Are you compiling for the correct processor, ie. have you selected the correct one in the dropdown list?
    What version of PBP are you using? Since you started two weeks ago I'm guessing it's PBP3.

    Can you post the code, all of it, as it currently stands?

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