EE2004 Cheatsheet
EE2004 Cheatsheet
d = 0: Store the result in WREG,d = 1: Store the result back in the file register
(fileReg).)
:
D) when MOVWF 40H is executed
Test2
Q6)
Address of R0:300H
what are the roles of the address of the first location in this user stack:302H
hardward stack in PIC18.Roles: What are the address modes of the instruction MOVEE RO,
Storing return addresses, PREINCO? Direct Addressing mode and Indirect addressing mode
automatic management, and Show the contents of FSRO Show the contents
interrupt handling. when "MOVLW OxFF" is of hardware stack
executing. 303H and stack pointer
Show the contents of when "MOVLW
hardware stack and stack OxOF" is
pointer when "MOVLW executing. Stack
OxFF" is pointer =2
executing.stack pointer = 1 stack[0002AH,0001
stack[00018H,empty] 8H,empty]
=
b) to propagate the possible carry to high
order addresses/ make possible
correction on the high order address
-2*(1/8+1/16)
ANS
ORG 0x008
BTFSC INTCON0, INT0IF
B1)Do not know the receiver is ready/busy or not
Do not know the receiver gets the data or not
MAIN:
B2)ADD CLRF TRISD before BSF INTCON, INT10E
BSF TRISB,1 Change MOVFF PORTC, 00H to MOVFF PORTC, PORTD
SETF TRISC
BCF INTCON,INT10E
BCF INTCON,INT10F
BCF INTCON2,INTEDG0
BSF INTCON, GIE
Main ORG 0x0000 TAD must be at least 1.6us. For fOSC = 4MHz or TOSC = 0.25us, the minimum possible TAD that can be chosen is 8TOSC or 2us. => fOSC/8 =>001
MOVLB 0xE0
TACQ must be at least 10µs. TAD = 2us. TACQ = 6 TAD =>011
MOVLW 0x01
Again CPFSEQ 0x00, 1 ADCON2=10 011 001 = 0x99
bra Again start
MOVF 0x01, w, 1 movlw 0x3B ; useAN2 and AN3 as reference voltages
movwf ADCON1 ; configure channel AN0-3 as analoginput
End movlw 0x99 ; select FOSC/8 as conversion clock,
movwf ADCON2 ; 6 TAD for acquisition time,
;right-justified
Assume fOSC = 4MHz, write a few instructions to configure PIC18F4520
ADC with the following requirements: movlw 0x01 ; select channel AN0 and enable A/D
movwf ADC converts the analog signal fed into Channel AN3. movwf ADCON0
b. Set AN0 to AN3 as analog inputs, other A/D port pins for digital I/O. bsf ADCON0,GO,A ; start A/D conversion
wait_con0
c. ADC result is left justified.
btfsc ADCON0,DONE,A ; wait until conversion is done
d. Select VDD and VSS as reference voltages. bra wait_con0
e. Select the minimum possible TAD movff ADRESH, 1 ; save conversion result
f. Select the minimum possible TACQ movff ADRESL, 0 ; "
g. Turn on ADC module
Do not start ADC yet movlw 0x05 ; select channel AN1 and enable A/D
TAD must be at least 0.7us and TACQ must be at least 1.4µs. movwf ADCON0
bsf ADCON0,GO,A ; start A/D conversion
Ans: TAD must be at least 0.7us. For fOSC = 4MHz or TOSC = 0.25us, wait_con1
the minimum possible TAD that can be chosen is 4TOSC or btfsc ADCON0,DONE,A ; wait until conversion is done
bra wait_con1
1us.
movff ADRESH, 3 ; save conversion result
TACQ must be at least 1.4µs. TAD = 1µs. TACQ >= 2 TAD movff ADRESL, 2 ; "
A = 39 (decimal):
Convert to binary:
39(dec)= 00100111(Bin)
B = 87(decimal):
Convert to binary:
87 = 01010111