PDA

View Full Version : Kind of stuck



gti_uk
- 31st May 2009, 00:16
Hello,

Ive got a really simple problem but i cannot see why i can not sort it.

Im using a K8048 board with the standard 18pin 16F627A pic. Ive managed to hook it up and ive compiled the blink app in mplab and put it on the pic fine.

The problem is ive tried to drop a if statement in as i thought it was a simple enough thing to do next. Only problem is it does not work :confused:

This is the code ive done


OPTION_REG = %11010111 'Set PIC options (See datasheet).
TRISA = %11111111 'all RA ports are inputs
TRISB = %11000000 'RB7 & RB6 are inputs.RB5...RB0 are outputs.


led1 var portB.0
led2 var portB.1
sw1 var portA.0


loop:

if sw1 = 1 then Goto loop

high led1 ' Turn on LED connected to PORTB.0
low led2
Pause 500 ' Delay for .5 seconds


low led1 ' Turn off LED connected to PORTB.0
high led2
Pause 500 ' Delay for .5 seconds



Goto loop ' Go back to loop and blink LED forever
End


This is part of the schematic for the k8084
http://i120.photobucket.com/albums/o170/gti_uk/schem1.jpg

Ive looked at the code and ive got the A bank set as an input, and the push button goes to RA0.

Any ideas where ive gone wrong, and sorry for such a dumb problem

Archangel
- 31st May 2009, 00:22
Try CMCON = 7
It disabled comparators on Port A

gti_uk
- 31st May 2009, 08:40
thanks loads Joe,

That worked a treat. As my second app, ive just changed my app to do the knight rider led thing.


Thanks again

Trev

ardhuru
- 31st May 2009, 09:39
Different pics would require different arguments to achieve this; disable the comparator, disable the adc and so on.

Make things simpler for yourself; just add darrel Taylor's alldigital.pbp as an include to your code to never having to bother remembering it in the future. Available at http://www.picbasic.co.uk/forum/showthread.php?t=11100

Regards,

Anand

flotulopex
- 31st May 2009, 11:57
Hi Trev,

I did something similar a year ago http://home.citycable.ch/flotulopex/K2000/KIT2000_Frames_e.htm

Maybe this gives you some other ideas ;)

gti_uk
- 31st May 2009, 17:02
thanks for the replys guys, im loving the idea of being able to just code a pic to do stuff that would take a fair circuit to do.

Ill add that all digital file to my pic programming stuff.

Is there any good book that talks of good programming practices with pics, ie use this command instead of that ect?

Thanks again

Trev

Archangel
- 31st May 2009, 20:45
Is there any good book that talks of good programming practices with pics, ie use this command instead of that ect?

Trev
:D . . . BRUCE is still writing it . . . :D