Jorge Hernández Garay
Newbie level 2
- Joined
- Nov 9, 2014
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 52
Hi guys! firstly thank you everyone for this excellent forum and for the help i'll receive even before i get it!
i'm a newbie in coding Assambly, i have a really terrible teacher and most of the time we students need to figure it out by ourselves.. not fair at all...
anyway... i need to create a code for counter delay of 99mS and i have no idea in how to start! i did before a simple one of 7ms but this new one use 16 bits and tmr1h tmr1l etc....
could you please guys give me a hand? what i've done was this:
thank you in advance~~!!!!!!
i'm a newbie in coding Assambly, i have a really terrible teacher and most of the time we students need to figure it out by ourselves.. not fair at all...
anyway... i need to create a code for counter delay of 99mS and i have no idea in how to start! i did before a simple one of 7ms but this new one use 16 bits and tmr1h tmr1l etc....
could you please guys give me a hand? what i've done was this:
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 ;SET CONFIG REGISTER __CONFIG _CONFIG1,_LVP_OFF& _FCMEN_ON& _BOR_OFF& _CPD_OFF& _CP_OFF& _MCLRE_ON& _PWRTE_ON& _WDT_OFF& _INTRC_OSC_NOCLKOUT __CONFIG _CONFIG2,_WRT_OFF& _BOR21V ERRORLEVEL -302 ;MACROS BANK0 MACRO ;SET UP MACRO TO SWITCH TO BANK 0 BCF STATUS, RP0 BCF STATUS, RP1 ENDM BANK1 MACRO BSF STATUS, RP0 BCF STATUS, RP1 ENDM BANK3 MACRO BSF STATUS, RP0 BSF STATUS, RP1 ENDM ;*************** VARIABLE DEFINITIONS ************************************************************** COUNT1 EQU 0X20 ;USED FOR DELAY LOOP COUNT2 EQU 0X21 ;USED FOR DELAY LOOP ;********************************************************************************************************* ;PROGRAM START ORG 0X000 ;PROCESSOR RESET VECTOR GOTO MAIN ;GO TO BEGINNING OF PROGRAM MAIN CALL SETUP CALL DELAY_TEST ; GOTO REPEAT ;********************************************************************************************************* ;************************** SETUP PROCEDURE ************************************************************** ; Initial settings for Pic Ports and Peripherals' ;********************************************************************************************************* SETUP BANK0 ;SWITCH BANK TO BANK 0 CLRF PORTA CLRF PORTB ;SET UP INITIAL PORTB O/P CONDITIONS CLRF PORTC CLRF PORTD CLRF PORTE BANK1 ;SWITCH TO BANK1 MOVLW 0XF0 MOVLW TRISA ;SET TRISA TO ALL O/Ps CLRF TRISC CLRF TRISD BSF TRISE, 0 MOVLW 0X07 MOVWF OPTION_REG BANK3 CLRF ANSEL CLRF ANSELH BANK0 ;SWITCH BACK TO BANK 0 RETURN ;******************************************************************************************************** ;********************* DELAY FOR APPROX 22mS *********************************************************** ; MAXIMUM DELAY AVAILABLE APPROX 65mS (4MHz PROCESSOR) ;******************************************************************************************************** DELAY_TEST BCF INTCON, T0IF MOVLW 0XAA ;SET UP DELAY COUNTERS MOVWF TMR0 XX BTFSS INTCON, T0IF GOTO XX RETURN ;******************************************************************************************************** END
thank you in advance~~!!!!!!