Sunteți pe pagina 1din 9

FAMU- FSU College of Engineering

Department of Electrical and Computer Engineering


Fall 2012 Semester

Jigar Patel Page 1 of 9

EEL-4746L Microcontroller Based Systems
Design Lab Report





Section No: 02



Lab Instructor: Soumak Mookherjee



Lab No: 06



Lab Title: Using CodeWarrior IDE to
program SLK-PB using ASM


Name: J igar Patel



Partners Name: Deneuve Brutus



Date Performed: 10/24/2012 10/31/12



Date Delivered: 11/07/12





EEL-4746L Microcontroller Based Systems Design Laboratory
Report

Jigar Patel Page 2 of 9



Contents

1. Introduction ...................................................................... 3
2. Requirements ................................................................... 3
3. Theoretical Design ........................................................... 3
4. Synthesized Design ......................................................... 3
5. Simulation Results ........................................................... 7
6. Experimental Results ....................................................... 8
7. Summary .......................................................................... 9
8. Lessons Learned .............................................................. 9


EEL-4746L Microcontroller Based Systems Design Laboratory
Report

Jigar Patel Page 3 of 9


1. Introduction
The purpose of this lab was to give student knowledge on the use of Assembly
programming language to implement delays using the different methods. The
methods introduced in this lab to create delays were as follows:
I. Software Delays
II. Polling Delays
III. Interrupt Delays
2. Requirements

3. Theoretical Design




/

SW [1:0]
4-bit
HEX
Counter
00





01




10
Hold
Mode
Count
with
Software
Delay
Count
with
Polling
Hex to
LED
Display
LED 1
LED 2
LED 3
LED 4
SLK PB LEDS
LED 2
LED 1
A
p
p
l
i
c
a
t
i
o
n

B
o
a
r
d

L
E
D
S

EEL-4746L Microcontroller Based Systems Design Laboratory
Report

Jigar Patel Page 4 of 9

4. Synthesized Design
; export symbols
XDEF Entry, _Startup ; export 'Entry' symbol
ABSENTRY Entry ; for absolute assembly: mark this as application entry point

; Include derivative-specific definitions
INCLUDE 'derivative.inc'

ROMStart EQU $4000 ; absolute address to place my code/constant data
;****************************************************
; Enter your equates here
;****************************************************
EOS EQU $00
PACONF EQU %00001111 ;conf bits 0:3 (active low)
PBCONF EQU %00110000 ;conf bit 4:5 (active high)
BIT7 EQU %10000000
BIT6 EQU %01000000
BIT5 EQU %00100000
BIT4 EQU %00010000
BIT3 EQU %00001000
BIT2 EQU %00000100
BIT1 EQU %00000010
BIT0 EQU %00000001
; variable/data section

ORG RAMStart
;*********************************************
; Place your variables here
;**********************************************
SW1 DC.B 1
SW2 DC.B 1
Count DC.B 2
value DC.B 1
;Count_Seq DC.B $1,$3,$5,$9,$B,$D,$F,$0
; code section
ORG ROMStart

;*****************************************************
; Enter your constants here
;******************************************************
PUCRCONF EQU BIT0 ;conf bit 0 of PUCR
DDRPCONF EQU PBCONF ;conf bit 4:5 of DDRP
POLL_CONF EQU %00000000 ;interrupt off prescale at 1
INT_CONF EQU BIT7
;Use these values to get the specified software delay:
;*~~~* N =M *~~~*
;Delay =(60sec)/(Count)
;LED Delay =(Delay / (Sequence #s)
;N Value =sqrt{[(2E6)(LED Delay)] / 3}
;********************************************
;| Count | Delay | LED Delay | N Val. |
;| 03 | 20s | 02.50s | 1291 |
;| 06 | 10s | 01.25s | 912.87 |
;| 12 | 05s | 0.625s | 645.49 |
EEL-4746L Microcontroller Based Systems Design Laboratory
Report

Jigar Patel Page 5 of 9

;| 18 | ~3s | 0.417s | 527.05 |
;********************************************
SOFT_1 EQU 1291 ;correct number to get 60 sec delay N=M=6324
SOFT_2 EQU SOFT_1
;Use these values to get the specified polling delay:
;********************************************
;| Count | Delay | LED Delay | N Val. |
;| 03 | 20s | 02.50s | 76.294 |
;| 06 | 10s | 01.25s | 38.147 |
;| 12 | 05s | 0.625s | 19.073 |
;| 18 | ~3s | 0.417s | 12.716 |
;********************************************
POLL_CNT EQU 76 ;correct number to get 60 sec delay N=M=6324
INT_CNT EQU POLL_CNT
;use the correct set of declarations based on the
;intput or output in lab

;*****************************************************
; Place Timer ISR here
;*****************************************************
TIMER_ISR:
SEI
DEC Count ; Fixed global variable
BNE Reset ; Time has not expired yet
J SR Update_Counter ; Delay time has expired, Update Display
LDAA #INT_CNT
STAA Count ; Reset Counter for next time interrupt occurs
BCLR TSCR2,BIT7
BRA Return1
Reset: LDAA #BIT7
STAA TFLG2 ; Reset TOF flag
BSET TFLG2,BIT7
CLI
Return1: RTI ; Need to Return from interrupt

;*****************************************************
; Place your subroutines here
;*****************************************************
Init_IO: CLRB ; "
STAB DDRA ; "
BSET DDRA,PACONF ;sets bits 0:3 in DDRA
CLRB
STAB DDRB
BSET DDRB,PBCONF ;sets bits 4:5 of DDRB
BSET PUCR,PUCRCONF ;sets bit 0 of PUCR
BSET DDRP,DDRPCONF ;sets bits 4:5 of DDRP
RTS ;returns to main

Count_Reset:
BRSET PORTA,BIT5,Count1
LDY #Count_Seq
LDAB 1,Y+
STAB PORTA
Count1: RTS

EEL-4746L Microcontroller Based Systems Design Laboratory
Report

Jigar Patel Page 6 of 9

Update_Counter: ;A =A +1
BRCLR PORTA,BIT6+BIT7, Hold
J SR Count_Reset
LDAB 1,Y+
STAB PORTA
CMPB #$00
BNE Return
PB5: LDY #Count_Seq
Return: RTS ;return to main

Software_Delay: ;Delay_Time =(3*(N*M))/(2E6)
PSHA
;BRCLR PORTA,BIT6+BIT7, Hold
LDD #SOFT_2 ;sets delay counter
L0: LDX #SOFT_1 ;sets delay counter
L1: DBNE X,L1
DBNE D,L0
PULA
RTS

Polling_Config:
LDAB #POLL_CONF
STAB TSCR2
LDAB #BIT7
STAB TSCR1
RTS

Polling_Delay:
PSHA ;saves counter to register
PSHB
LDX #POLL_CNT ;Need to wait POLL delay cycles
L2: TST TFLG2 ;Tests TOF (Bit7 of T Flag)
BPL L2 ;Branch to L2 if TOF =0
LDAB #BIT7 ;Reset TOF, need to write 1 in TFLG2
STAB TFLG2
DBNE X,L2
PULB
PULA
RTS

;******************************************************
; Place your main routine here
;*******************************************************
Entry:
_Startup:
LDS #RAMEnd+1
CLI
J SR Init_IO ;calling subroutine INIT_IO
CLRA ;initilize counter using register A
LDY #Count_Seq
J SR Update_Counter ;calls subroutine Update counter
LDAA #INT_CNT
STAA Count ; Set #of loops


EEL-4746L Microcontroller Based Systems Design Laboratory
Report

Jigar Patel Page 7 of 9

Main: J SR Count_Reset
BRSET PORTA,BIT7, Polling
BRSET PORTA,BIT6, Software
;Hold Mode
Hold: BCLR TSCR2,BIT7 ;disables interrupts
BSET PORTB,BIT4 ;turns LED1 OFF on Application board
BSET PORTB,BIT5 ;turns LED2 OFF on Application board
J SR Count_Reset
BRA Main
;Software Mode
Software: BCLR TSCR2,BIT7 ;disables interrupts
BCLR PORTB,BIT4 ;turns LED1 ON on Application board
BSET PORTB,BIT5 ;turns LED2 OFF on Application board
J SR Software_Delay
J SR Update_Counter
BRA Main
;Polling Mode
Polling: BRSET PORTA,BIT6,Interrupt
BCLR TSCR2,BIT7 ;disables interrupts
BSET PORTB,BIT4 ;turns LED1 OFF on Application board
BCLR PORTB,BIT5 ;turns LED2 OFF on Application board
J SR Polling_Config
J SR Polling_Delay ;calls subroutine
J SR Update_Counter
BRA Main

;Interrupt Mode
;Did not do this mode
Spin: BRA Spin

Count_Seq DC.B $1,$3,$5,$9,$B,$D,$F,$0
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG $FFDE
DC.W TIMER_ISR
ORG $FFFE
DC.W Entry ;Reset Vector
5. Simulation Results
N/A

EEL-4746L Microcontroller Based Systems Design Laboratory
Report

Jigar Patel Page 8 of 9

6. Experimental Results




EEL-4746L Microcontroller Based Systems Design Laboratory
Report

Jigar Patel Page 9 of 9

7. Summary

As seen above the lab was a success. The coding wasnt too bad with minor speed
bumps on the way. Interrupt Mode was not done resulting in a fail for section 7.
Section 6 however was working but it wasnt correctly done. The value does get
reset but only after the delay loop has been exited. Meaning one has to hold PB4
down until count resets to first count due to the fact that the PB4 check wasnt in
the delay loops.
8. Lessons Learned
This lab was fairly easy a few things to watch out for were making sure that the
checks for the switches were done in the correct spots, also knowing the LEDs
and their orientation was important. i.e knowing which LEDs are active low and
which ones are active high helped a lot. All in all an easy lab provided the pseudo
code which was in the lab. The pseudo code was followed closely to obtain the
results making it a fairly easy lab.

END OF DOCUMENT

S-ar putea să vă placă și