medyo magulo nga talaga... paki explain pa po ng konti.
pero maganda nga... at since, nagC kaagad ako sa PIC. marahil ito ang pagkakataon na mapag-aralan ko ang assembly. nwei, ang importante ay ang masanay ako.
Sir, alin po ba magulo, iyong Alexan/DOST o iyong Program na naka post?
Iyong Alexan at saka DOST, mayroon daw sila sariling R&D, kaya iyong offer namin since 2004~2008 sa kanila were not welcome. We have gone through DECS, TESDA and CHED as well kasi nababasa namin noon na mayroon support ang government sa mga individual person, company and similar institution about boosting the technical education here in RP, seriously we did try na mag-avail sana and to be guided iyong tamang ways. Well, we'll do it again by 2008 4rth quater or by 2009.
Iyong naka post na program naman, its one of the sample Program in the Trainer Kit : STARTER MCU-EB8051-"2" Trainer Kit. Ang ginagawa lang ng program ay to "create a running lights".
Mayroon 8 LEDs na nakakabit sa AT89S51, mula Pin 1 (P1.0) hanggang Pin 8 (P1.7). Ang gagawin ng program ay paiilawin niya ang LED alternate :
Pattern 1 : 10101010 ---> LED_7, LED_5, LED_3, LED_1 = No LIGHT
LED_6, LED_4, LED_2, LED_0 = will Light
Pattern 2 : 01010101 ----> LED_7, LED_5, LED_3, LED_1 = will LIGHT
LED_6, LED_4, LED_2, LED_0 = No Light
Kung alternate ang Pattern 1 at saka pattern 2 endlessly, with about 500msec delay between pattern, ang kalalabasan ng 8 LED ay parang running lights.
Ang Instruction na :
MOV A, #10101010B ay byte command para i-load ang pattern 1 sa Accumulator (A) : A = 10101010. Ginamit ang Binary Notation kasi, mas madaling maintindihan ang sequence ng LED. ZERO means LIGHT LED, "1" means NO LIGHT LED ---> current sink driving the LED : Ang anode ng LED ay naka connect sa +5V via a 560 ohms limiting resistor, ang cathode ay nakaconnect sa MCU port, parang ginagawa ng MCU ay i-GND lang ang cathode para umilaw : zero = GND, "1"=V+, kaya para umilaw ang LED, dapat ang logic ay zero (para GND).
Ang instruction na :
MOV LEDOUT,A ipapasa ngayon ang laman ng "A" sa LEDOUT, at doon sa declaration ang LEDOUT ay Port 1 (P1). DI kasi puwede na gawin MOV P1 = A sa Assembly na ito, kagaya ng CHESS, may kanya kanyang movement ang mga bishop, King and Queen, ganun din ang mga register and ports, may kani kanilang movement sa memory. Oks, so ang laman ng P1 ngayon ay P1 = 10101010. At dito, iilaw na ang mga LED sa pattern 1.
Ang instruction na :
CALL DELAY, magkaroon ng about 500msec delay para makikita na iilaw ang mga LED. So kung about 500msec ang delay mo iyan din ang time kung gaano katagal iilaw ang mga LED.
(same lang po ang pattern 2).
Iyong DELAY--- ay subroutine po iyan, kung baga "Palipas Oras". Para magkaroon ng delay, ang program ay paikot-ikot sa Register R6 at saka R7. Ang R6 ay may value na 255 decimal, mag-decrement ito hanngang zero, tapos uulitin iyan 100 times (R7=100).
Ang Register R6 ay matatagpuan sa location memory address 006H (bank 0) at ang Register R7 naman ay matatagpuan sa memory address 007H (bank 0).
Itama ko lang typo "niya" :
DELAY:
MOV R7,#100 ;Set R7 to loop 100 times
OLOOP: MOV R6,#255 ;Set R6 to 255
ILOOP: DJNZ R6, ILOOP ;Decrement R6 by 1, if R6 is not equal
;to "0" then go to label ILOOP
DJNZ R7,OLOOP ;If R6 loops 255 times, decrement R7 by
;1 and if R7 is equal to 0, it will exit
;DELAY and go back to the Main
;Program.
If R7 is not equal to 0, then
;ILOOP RET ;Return to the Main Program
I hope Sir, nasundan niyo po ang logic ng program.
Of course, sa higher language, napakadali na gawin iyan, di po ba? Gaya ng advice sa akin noon, magsimula ka sa Assembly (kung di ka naman talaga nagmamadali and you are really like to study the Architecture), kasi, using Assembly instruction, you are required to know the "memory map", kasi dito sa memory map mo lang paiikutin (manipulate) ang iyong data. As I often described, parang chess board ang memory map ng Intel 8051, may mga movement ang bawat chess character, ganun din sa MCU, may movement ang bawat registers.
In the accompanying book - ang memory map ng Intel 8051 was compared to a Floor plan ng House, and then Registers are compared to a cabinet filling books, in the cabinet there is a rule to put the book, you can put the book one by one (bit manipulation) and also put the book 8 at a time (byte manipulations). It was explained in a simple way para madali ma-intindihan ---kopya lang iyan sa coding ng Resistor (diba, may coding din tayo sa Resistors in a "maniac definition" like,
Bad Boy Rape Our Young Girl But Violy Give it Willingly, instead na sasa bihin mo Black, Bowrn, Red, Orange......
I really hope we can offer the : EAFF - Easy, Affordable Fast and Fun ways of Learning MCU.