Delhi Technological University Assignment Embedded Systems
Delhi Technological University Assignment Embedded Systems
Delhi Technological University Assignment Embedded Systems
ASSIGNMENT
EMBEDDED SYSTEMS
Each bank extends up to 7Fh (128 bytes). The lower locations of each
bank are reserved for the Special Function Registers. Above the Special
Function Registers are General Purpose Registers, implemented as
static RAM. While program is being executed, it is working with the
particular bank. The default bank is bank0.
#include <xc.h>
#include "config.h" // Configuration bits file stored in a header file
#define _XTAL_FREQ 20000000 //define crystal frequency to 20MHz
// This array stores binary bit pattern that will be send to PORTD
unsigned char
binary_pattern[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6
F};
void main(void)
{
TRISD = 0x00; //define PORTD as a output pin
while(1)
{
//this loop sends all binary patterns to PORTD
for (int i=0;i<10;i++)
{
PORTD = binary_pattern[i];
__delay_ms(1000); //add delay of one second
}
}
return;
}
3.WAP for finding the even numbers among 10,8 bit numbers.
.model small
.data
arr1 db 1,2,3,1,3,5,6,3,4,5
OddArr db 10 dup(?)
EvenArr db 10 dup(?)
OddAdd db 0
EvenAdd db 0
.code
mov ax,@data
mov ds,ax
LEA BX,arr1
LEA SI,OddArr
LEA DI,EvenArr
mov cx,10
mov dh,02
L1:
mov ah,00
mov al,[BX]
mov dl,al
div dh
cmp ah,00
je EVEN1
mov [DI],dl
add OddAdd,dl
INC DI
INC BX
Loop L1
jmp CAL
EVEN1:
mov [SI],dl
add EvenAdd,dl
INC SI
INC BX
Loop L1
CAL:
mov ax,0000
mov bx,0000
mov al,OddAdd
mov bl,EvenAdd
mov ax,4C00h
int 21h
end
Timer 1
;initialize
Org 0010
Start bsf status,5; select memory bank 1
Movlw B’00011001’
Movwf trisa
Movlw 00
Movwf trisb
Movlw b’00011010’
Movwf TMR1
Bcf status, 5
Timer 2
Movlw d’249’
Movwf pr2,A
Bsf RCON,IPEN,A
Bsf IPR1,TMR2IP,A
Bcf PIR1,TMR2IF,A
Movlw 0*C0
Movwf T2CON,A
Bsf PIE1,TMR2IE,A