Acidmods
AcidMods Resources ----- ( These are helpful tools for modding ) => Pic Programmers and Programs => Topic started by: drummerdude on September 10, 2011, 12:10:43 PM
-
So ive been trying to learn assembly recently.. im not very good at it as i only know some simple instructions. I want to get the chip to read a switch and then turn an led on or something. Ive tried like a million times trying o get the chip to read the switch. ive used peices from bmu to try. ive even copy/pasted the code for switches from the gooligum electronics page. nothing seems to work. i know its not the switch as i tested it using t0ps led chaser code. anybody wanna give me a hand and help me out?
-
Show us your best attempt? I would think its probably something to do with how you set up the port.
-
well here it is... i noticed that it does the button press when i tap the wire... not the switch...
-
OK.
First, you are using pin 5 as the input, but you do not use the weak pull ups. You will have to use a resistor on pin 5 to pull it up or else the button wont work correctly.
Second, you call your delay10 routine that moves the value in the work register to setup how many times the outer loop loops. The last value you had in thier was 60 from setting up the TRIS register, so it would loop for 0.6 seconds before continuing. You need to put a value into your dc3 register in the routine (like a value of 1).
Third, you never change the default ANSEL register to turn the analog function off. Although pin 5 is does not share an analog function, the pin you are using as an output (pin 0) does share an analog function and you need to change the ANSEL register to make the pins digital.
Fourth, putting a value of 15 for your delay routine will flash the output so fast you would never see it, it would just simply be dim. You need a value of 100.
-
Ha! Ha! I took your advice and it works! Thanks a lot!
-
you really need to go through all the tuts on Googligum, I have been through about 4 of them and they are really useful, it takes time but it pays off :)
-
So i made an led color changer last night when i go my problem fixed... i know its kinda unnecessary since there's already 3 of them made, but i just wanted to make my own.. anyway here it is..
http://www.youtube.com/watch?v=r3J45eTnBQ0
-
Nice work coming along good there . hope i can keep up with the competition ;)
-
So im working on an abxy flasher type code... So the code works fine until you get to the last mode.. after the last mode, its soppost to go back to off, but instead it doesnt... not really sure whats going on, jus like i said before, i dont know exactly what im doin... lol... mabe someone could take a look at it and tell me whats wrong possibly...
-
At a glance there is problems with your test routines.
- test2 which is called from the end of the chase mode only leads to chase or blink not off, I believe this to be why your code won't go back to the off mode
- also test and test2 should not be "called" or how you have them currently will cause the call stack to overflow after you change mode a few times, because you call them but then if the button is pressed a return instruction is never given. I would change "call test" to "goto test" then replace the return at the end of test with "goto blink" (you will also need to change test 2) this will stop the stack overflowing.
Also I noticed these, they aren't stopping it from working but they aren't helping
- You are controlling the LEDs directly in your main loop, it would be better to set up a timer interrupt then have the main routine deal with the button reads and current mode and tell the interrupt what to do using flags registers.
- when reading the button whilst in the last 2 modes you don't de-bounce the button reads nor do you wait for it to be released before continuing.
Sorry i'm not too good at explaining stuff so if you don't get any of that let me know :P
-
So i remember i changed it to goto somewhere instead off goto off, since i wanted to see if it worked from a different label
I also changed my calls to gotos.. and i changed the tests to this..
test
btfss GPIO, 4
call debounce
btfsc GPIO, 4
goto chase
goto Blink
test2
btfss GPIO, 4
call debounce
btfsc GPIO, 4
goto off
goto chase
and it still didnt work... and its even worse now.. it just toggles an led on and off and doesnt do any modes... not sure what happened...
id like to know how to write an interrupt also.. ive read about them, but ive never written one before.. but id like to get to that once i an get this to work..
-
Yay! my 0603 leds came in today! so i can attempt to do the 7mode color mod! I love my led provider... they arent the chepest prices but they have fast shipping, usually they only give me 1 extra led, but ive bought from them countless
times now so they gave me 4 xtra leds! also i still didnt get my code fixed either.
edit: ive been looking for batteries for the last half an hour and i cant find any... so much for doing that mod today
-
So ive been thinkin bout the code today, and if you change the call to gotos and then have goto blink or whatever, then it will just keep on repeating the 1 instruction and wont do the whole thing... is there like a return for gotos or something i can do to counteract this?
-
OMG, so i decided to have multiple different button tests for each mode and each test brought you 2 the next instruction, and it worked! i just tested the code and it worked pretty much fine, although i did have 2 press the switch a second time 2 get it to change. so if you wanna look at it and maybe help me out with something, idk, here it is.
-
this is my final ABXY flasher code. Now its time to move on to the next code...
http://www.youtube.com/watch?v=yfD3osp5-NU
-
Thats awesome man! well done for actually completing something :D
-
Thanks a lot! I worked really hard on it. thanks for all the help too.
-
Thats awesome man! well done for actually completing something :D
Wow thats awsome I agree, with hyper also , nice job Congrates on such anice flasher :)