Few start point
http://www.picbasic.co.uk/forum/show...hlight=dummies
Code:; Super dooper LED blink with 10F200 ; ================================== ; Steve Monfette ; Mister E ; 23/03/2006 ; As if the world really needed it... well it's still usefull ; to learn a bit how to play and waste your time using the ; annoying assembler language. BTW 10F200 are just too small ; to accept any other language. ; This program will use a software loop delay, called by a macro ; wich will pass the delay to produce... at least not too basic and ; some part could be usefull.. one day if someones really try to figure ; out how it works... just kidding.. i know EVERYBODY WILL TRY ;o) ; --------------------------------------------------------------------- INCLUDE "P10F200.INC" ; load all needed stuff ; PIC configuration ; ================= __Config _MCLRE_ON & _CP_OFF & _WDT_OFF ; Hardware assignement ; ==================== #define Led GPIO,2 ; RAM assignement ; =============== ; hands-up those who discover figure 4-3 cblock 0x10 loop UserDelay endc ; Macro Definition ; ================ ; Be carefull, the following macro is extremely difficult to understand ; and contain tons of information... always refer to MPASM book to ; understand all trick it do.. mpff mkay i stop it :o) ; Nothing fancy, the macro will just pass the parameter to the 1 msec ; subroutine -> Delay <- Not much. What could she do more to be still ; code efficient anyway? Delayms macro User movlw User ; put User wish somewhere movwf UserDelay ; copy it to something call Delay ; do the delay endm ; ///////////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ; Program Begining ; ///////////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ; Hardware configuration ; ====================== ORG 0 ; movwf OSCCAL ; Load OSCCAL value movlw b'11111011' ; TRIS GPIO ; Set GP2 as Output movlw b'11011111' ; TOCS=internal => to use GP2 as Output OPTION ; => datasheet section 4.5 ; Tha ****! ; ========= ; The exciting part of the program... how to blink a LED Start bsf Led ; Enable LED Delayms d'250' ; do 250 mSec Delay bcf Led ; Disable LED Delayms d'250' ; do 250 mSec Delay goto Start ; Have fun forever, enjoy the show ; Delay Subroutine ; ================ ; The main program call the macro, the macro call this routine Delay movlw d'250' ; 1 mSec base movwf loop ; loop ; DelayLoop ; --------- nop ; do nothing (1 Cycle) decfsz loop,f ; base loop finished? (1 cycle if NO, 2 cycle if YES) goto $-2 ; NO... jump 2 lines before (2 cycles) ; ------------------------------- ; Killed about 4 cycles * 250times @1uSec = 1mSec ; decfsz UserDelay,f ; DelayFinish? goto $-6 ; NO... do it again, jump 6 line before retlw 0 ; Astalavista baby end




Bookmarks