How's this for Spaghetti Code
PORTA.1 = 0 :PORTA.2 = 0 :PORTA.3 = 0 :PORTA.4 = 0 :PORTA.5 = 0 :PORTA.6 = 0
How's this for Spaghetti Code
PORTA.1 = 0 :PORTA.2 = 0 :PORTA.3 = 0 :PORTA.4 = 0 :PORTA.5 = 0 :PORTA.6 = 0
A friend of mine writes code that way. Here is a mild sample.
http://www.picbasic.co.uk/forum/showthread.php?t=5407
After you do it that way for awhile it begins to make sence.
Dave
Always wear safety glasses while programming.
Boat-load of errors in wbubels code Dave.
Got an E-Beer ready for the first one to fix em all & explain in detail why...;o}
Last edited by Bruce; - 31st July 2009 at 01:06.
HiYa wbubel,
PortA = %01000000 means portA.6 is going high when port is made an output, so if it crosses that place in space time while the PIC is initializing you will see PortA.6 output high. You want to set PortA.6 as zero and do it before you set the tris register to input or output so when it becomes an output or input the latch register is set in a known state, setting it as 1 does not enable pullups or anything like that, so you should have:
You ever watched an old mechanical slot machine? Figure your registers are going like that until the pic boots and settles into the default mode, usualy 11111111, then it follows your code.Code:PortA = %00000000 ' set port latches low TrisA = %01000000 ' make RA6 input
Last edited by Archangel; - 31st July 2009 at 02:21.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Here is your code with comments . . .changesCode:DEFINE OSC 4 'Define the Osc to 8 MHz asm bsf OSCCON, SCS1 ; 1x = Internal Block bcf OSCCON, SCS0 ; 00 = Primary Oscillator (20Mhz?) bsf OSCCON, IRCF2 ; 111=8000 110=4000 101=2000 bsf OSCCON, IRCF1 ; 100=1000 011=0500 010=0250 bcf OSCCON, IRCF0 ; 001=0125 000=0032 MSTABLE010 btfss OSCCON, IOFS bra MSTABLE010 ; wait until Oscillator is stable endasm data @0,0 'Initialize location 0 on eeprom to zero LED2 var PORTB.2 ' LED cntr var word FET var PORTA.0 'PORTB = %00000100 ' Clear PORTB, and set B2 PortB = %00000000 ' clear port latch bits 'PORTA = %01000000 ' Clear PORTA PortA = %00000000 ' Clear PortA latches 'TRISA = %01000000 ' Set PORTA port 2 and 7 to input, 0, 3-6 ,8 Output TRISA = %10000100 'Set PORTA port 2 and 7 to input, 0, 3-6 ,8 Output TRISB = %00000000 ' Set PORTB to all output led2 = 1 ' PortB.2 high LED on read 0,cntr 'read location 0 or eeprom FET = 0 ' PortA.0 Low if (PORTA.7 = 0) then pause 255 ' pause 255 milliseconds If (PORTA.7 = 0) then write 0,0 'reset eeprom to 0 when port A Bit 7 has been forced to 0 Main: led2 = 0 'PortB.2 Low LED off pause 64 ' very strange choice of pause 64 milliseconds led2 = 1 ' LED on if (cntr < 10) then Pause 255 'slow blink under ten cycles cycles of what ? pause 255 ' why this duplicate pause is good for something like 65535 ms else Pause 64 'fast blink over 10 cycles cycles of what ? endif cntr = cntr + 1 'increment cntr write 0,cntr 'write new cntr value into eeprom if (cntr <= 20) then goto main FET = 1 'Shut down RF Current ' cntr = 0 'stop stop stops all brain activity how can it goto main? goto main 'Stop End
Last edited by Archangel; - 31st July 2009 at 03:33.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
i need help i've tryed this code and when i add more text in ldata var it says error enable to fit ldata variable, and i changed ldta to var bit but it shows all LDEs on how can i fix this problem to add more scrolling text please help
Code:DEFINE OSC 4 TRISA = %00000 TRISB = %00000000 column var byte dchange var byte scan var byte scroll var byte ldata VAR BYTE [59] when i change to bit it shows all leds on? START: CLEAR ldata [0] = %11111 ldata [1] = %11111 ldata [2] = %11111 ldata [3] = %11111 ldata [4] = %11111'END OF CLEAR ldata [5] = %01000 ldata [6] = %01010 ldata [7] = %00010 ' S ldata [8] = %11111 '_ ldata [9] = %00000 ldata [10] = %11011 ldata [11] = %00000 'H ldata [12] = %11111 ldata [13] = %00001 ldata [14] = %11010 ldata [15] = %00001 'A ldata [16] = %11111 ldata [17] = %00110 ldata [18] = %01010 ldata [19] = %01100 'Z ldata [20] = %11111 ldata [21] = %11111 ldata [21] = %00001 ldata [22] = %11010 ldata [23] = %00001 'A ldata [24] = %11111 ldata [25] = %11111 ldata [26] = %00000 ldata [27] = %11101 ldata [28] = %11011 ldata [29] = %00000 'N ldata [30] = %11111 LDATA [31] = %00000 LDATA [32] = %01110 ldata [33] = %10001 'D ldata [34] = %11111 ldata [35] = %11111 ldata [36] = %11111 ldata [37] = %00000 ldata [38] = %11101 ldata [59] = %11011 ldata [39] = %11101 ldata [40] = %00000 'M ldata [41] = %11111 ldata [42] = %00000 ldata [43] = %01111 ldata [44] = %00000 'U ldata [45] = %11111 ldata [46] = %01000 ldata [47] = %01010 ldata [48] = %00010 ' S ldata [49] = %11111 ldata [50] = %11111 ldata [51] = %11001 ldata [52] = %10110 ldata [53] = %01101 ldata [54] = %10110 ldata [55] = %11001 'HEART ldata [56] = %11111 ldata [57] = %11111 ldata [58] = %11111 ldata [59] = %11111 'SPACE LOOP: FOR scroll = 0 TO 54 FOR scan = 0 TO 59 PORTB = 1 FOR column = 0 TO 7 PORTA = ldata [column] PAUSE 1 PORTB = PORTB * 2 NEXT NEXT FOR dchange = 0 TO 59 ldata [dchange] = ldata [dchange+1] NEXT NEXT GOTO START END
Last edited by Mus.me; - 1st August 2009 at 00:01.
Bookmarks