![]() | ![]() | ![]() |
| | #16 |
|
Ya you lost me at RLF haha wow this may seem alot more complicated then I thought it would be there's no simple way to take a string and seperate it is there ? haha I've just looked on google with little answer's the only problem is that the 509 doesn't have a interrupt so im not sure what to do from there. I know how to place the string into a variable then read that variable im just not sure how to take each bit apart. I also know how how to write it too the pin I just can't take the bit's apart and thats the problem bc soon as I get that my code goes from a whole bunch of lines to almost half and making sequences are so much easyer as well. Also I think if I understand it right your way of doing it with RLF will only allow me to have on pin on at a time
Last edited by Darkstar64; 5th September 2008 at 04:16 AM. | |
| |
| | #17 | |||||
| Quote:
![]() Quote:
Quote:
Quote:
Sounds very much like you need to work up to a project like this. Start with some simpler projects (sub-sections of this project would be great!) and gradually you'll learn the things you need to know to tackle tougher projects like a LED cube. Quote:
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 5th September 2008 at 04:45 AM. | ||||||
| |
| | #18 |
|
ok ya I might have to work up to it like you said can you give me a few project names or links too where I can start learning more about this ?
| |
| |
| | #19 | |
| Quote:
Once you have that working, take the high nybble of one byte and use that to light the left 4 LEDs and take the low nybble of another byte and use that to light the right 4 LEDs. Have fun!
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 5th September 2008 at 03:23 PM. | ||
| |
| | #20 |
|
Srry im still not understanding We have the whole thing figured out other then the engine now looking at one that was made before by someone ealse who was helping me but we were not using shift regiesters at the time it looks like this using just the I/0 pins on the PIC. Also since im going to be using all the I/0 pins on the pick what do I need to do In curcuit programming. I'm not sure what pins the 509 uses to program and what I need to do to seperate the PIC from the rest of the curcuit as well. When I am programming the PIC I know it needs to be seperated from everything so that it doesn't fail in programming. Ok I get what rlf and rrf do now they move the bits left and right now from there I just write the carry bit to the data pin and move to the next bit right ? Now how do I write the carry flag im not sure what location its in ? Basically your telling me to first set what LED's I want on by something like this b'10100100'. Then I would use RLF to move the first bit into the carry flag and write that to the data pin. Then I would then use RLF again and that would take the bit in the carry flag and move it too the end so it would then be '01001001' right ? and put the new bit in then I would write that to the shift etc etc ?
Last edited by Darkstar64; 5th September 2008 at 04:00 PM. | |
| |
| | #21 |
|
srry for the double post but like this ? Im still not sure how to access the carry flag im not sure the location of it ? and would I be able to do the same thing with a 12 output shift register using 12 digits instead of 8 ? like so '000000000000' then do the same thing with RLF to move it into the carry flag like the same thing with the 8 output shift Code: C 76543210
0 00000001
RLF 0 00000010
RLF 0 00000100
RLF 0 00001000
RLF 0 00010000
RLF 0 00100000
RLF 0 01000000
RLF 0 10000000
RLF 1 00000000
RLF 0 00000001
Last edited by Darkstar64; 5th September 2008 at 04:41 PM. | |
| |
| | #22 | ||||||
| Quote:
Quote:
Quote:
Quote:
Use a BTFSC or BTFSS to test the carry bit and either write one value if no branch or if there is a branch to write the other value to the data pin. Quote:
Quote:
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | |||||||
| |
| | #23 | |||
| Quote:
Quote:
Quote:
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 6th September 2008 at 01:57 AM. | ||||
| |
| | #24 |
|
Basically the whole thing would look something like this right ? but im having some build errors all post them under the code Code: ;******** Main Code
start
movlw b'001000' ; Configure only GP3 as a input
tris GPIO
loop
movlw b'00100001'
movwf Display
call Engine
goto loop
;******** Subroutines
Engine
RLF Display
call test_clock
RLF Display
call test_clock
RLF Display
call test_clock
RLF Display
call test_clock
RLF Display
call test_clock
RLF Display
call test_clock
RLF Display
call test_clock
RLF Display
call test_clock
movlw b'000100'
movwf GPIO
retlw 0
test_clock
BTFSC 03h,b
movlw b'000000' ; Moves 0 on Data pin
movwf GPIO
movlw b'000010' ; Clocks it
movwf GPIO
movlw b'000000'
movwf GPIO
BTFSC 03h,b
movlw b'000001' ; Moves 1 on Data pin
movwf GPIO
movlw b'000010' ; Clocks it
movwf GPIO
movlw b'000000'
movwf GPIO
retlw 0
END ; End of Program !
Code: ---------------------------------------------------------------------- Debug build of project `C:\PIC12F509\Programs\LED_Matrix.disposable_mcp' started. Preprocessor symbol `__DEBUG' is defined. Sat Sep 06 13:45:30 2008 ---------------------------------------------------------------------- Clean: Deleting intermediary and output files. Clean: Done. Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p12F509 "LED_Matrix.ASM" /l"LED_Matrix.lst" /e"LED_Matrix.err" /d__DEBUG=1 Error[149] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 57 : Directive only allowed when generating an object file Error[149] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 62 : Directive only allowed when generating an object file Message[305] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 85 : Using default destination of 1 (file). Message[305] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 87 : Using default destination of 1 (file). Message[305] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 89 : Using default destination of 1 (file). Message[305] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 91 : Using default destination of 1 (file). Message[305] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 93 : Using default destination of 1 (file). Message[305] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 95 : Using default destination of 1 (file). Message[305] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 97 : Using default destination of 1 (file). Message[305] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 99 : Using default destination of 1 (file). Error[113] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 106 : Symbol not previously defined (b) Error[113] C:\PIC12F509\PROGRAMS\LED_MATRIX.ASM 113 : Symbol not previously defined (b) Halting build on first failure as requested. ---------------------------------------------------------------------- Debug build of project `C:\PIC12F509\Programs\LED_Matrix.disposable_mcp' failed. Preprocessor symbol `__DEBUG' is defined. Sat Sep 06 13:45:31 2008 ---------------------------------------------------------------------- | |
| |
| | #25 |
|
One issue that I have not seen mentioned is the memory addressing limitations of baseline PICs of which the 12F509 is a member. These PICs have the instruction space divided into 512 word pages. Only the first 256 words of a page can be used as the destination of a subroutine call or instruction that modifies PCL. In addition, care must be taken that the page select bits in the STATUS register are set for a GOTO, CALL, or instruction that modifies the PCL. These characteristics can severely limit table lookups used for pattern generation. An inexpensive mid-range chip such as a 16F627A/628A is much better suited for this project and is probably cheaper in the long run, i.e. one PIC vs One PIC and two shift registers. | |
| |
| | #26 |
|
Yes many have said such things about getting a new PIC but as for now im sticking too the 509 untill I understand assembly much more. As of right now im just going back looking how I did things in the past following tut's etc... So at the moment I just need help on what ive written and if its correct or not and why its not building right ?
| |
| |
| | #27 |
|
Some of your errors I can't help with as you haven't included all your code. The Message[305]s are caused by not having a destination on your RLFs. You need either F for file or W for W tagged on the end of the instructions. I.E. Code: RLF Display,F or RLF Display,W I assume you are trying to test the Carry flag and if so it should be BTFSC STATUS,C. You should also note that this instruction only skips the following instruction, you appear to expect it to jump over several. Can I suggest you change your subroutine to, Code: test_clock movlw b'000001' ;value to send 1 bit BTFSS STATUS,C ;carry set movlw b'000000' ;no so use value to send zero bit movwf GPIO ;put it on port nop ;avoid RMW problem bsf GPIO,1 ; Clocks it nop ;short delay bcf GPIO,1 ;finish clocking retlw 0 Mike. | |
| |
| | #28 |
|
Thanks Mike all errors are fixed now so now all I have to do is just make my pattern and call the engine and it should understand what im giving it and write what I need to the Data Pin and clock it then go to the next pattern right since I now have the engine figured out ? And thanks again for helping my teacher is going to be happy haha
Last edited by Darkstar64; 8th September 2008 at 03:39 AM. | |
| |
| | #29 | |
| Quote:
I also remind you that the return stack is two levels deep so there is a servere restriction on the nesting of subroutines, at lest on those invoked with a CALL instruction. Perhaps it is best just to let you discover these thing for yourself! | ||
| |
| | #30 |
|
Hi skyhawk, I agree totally that switching to a better chip would be the best solution. However, you are not completely correct on your description of the 12 bit chips. On the 509 you can make calls to addresses in the 0x200-0x2ff region by setting the PA0 bit in status. You can also use the two pages that are not accessible to calls for tables as computed gotos will still work. Darkstar, What skyhawk states is so true. You are making your life so much harder by staying with the 12 bit chips. Switching to a 14 bit chip (12F683 - still 8 pins) will give you so much more flexibility. Mike. | |
| |
|
| Tags |
| pic, registers, shift, working |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| 16 bit serial in parallel out shift registers | forder | Electronic Projects Design/Ideas/Reviews | 14 | 2nd March 2009 09:17 AM |
| Cascading Shift Registers Help | Suraj143 | Electronic Projects Design/Ideas/Reviews | 13 | 5th June 2008 08:33 AM |
| Load shift-registers via SPI? | Mike, K8LH | Micro Controllers | 14 | 14th February 2008 03:00 AM |
| Help loading shift registers... | jrz126 | Micro Controllers | 0 | 14th November 2005 01:13 PM |
| shift registers | jrz126 | Electronic Projects Design/Ideas/Reviews | 8 | 25th September 2004 02:35 AM |