PDA

View Full Version : 16f873a issues, pbp beginner



Digryo
- 4th November 2011, 16:37
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

HenrikOlsson
- 4th November 2011, 17:19
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.

HankMcSpank
- 4th November 2011, 23:27
Henrik,

Apparently your PM is full!

rgds,
Hank.

HenrikOlsson
- 5th November 2011, 07:45
Thanks, it's fixed now.
Sorry for the OT.

/Henrik.

Digryo
- 8th November 2011, 18:43
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...

HenrikOlsson
- 9th November 2011, 07:50
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?