You are on page 1of 15

Adeel Pasha, LUMS, 2014-15

LAB-1: EasyPIC Development Board


I t d ti to
Introduction
t PIC18F452 & Family
F il

Adeel Pasha, LUMS, 2014-15

EE-522
EE
522 Term Schedule
W1:27/1
Intro

W1:29/1
RT-Scheduling

W2:3/2
Static Scheduling
Algos

W3:10/2
Dynamic Scheduling
Algos

W3:12/2
Mem-mapped I/Os,
GPIO etc.

W4:17/2
Lab1
(EasyPICV6/7)

W4:19/2
Lab2
(EasyPICV6/7)

W5:24/2
Aperiodic Schedulers

W5:26/2
Commercial RTOS

W6:3/3
Linux Device
Drivers

W6:5/3
Lab3
(VM-Linux Kernel)

W7:10/3
Commercial RTOS

W7: 12/3
Resource Sharing

W8:17/3
Lab4
(Mini6410)

W8:19/3
Mid term

W9:31/3
Lab5
(Mini6410)

W9:2/4
Resource Sharing in
MP

W10:7/4
RT Comm.

W10:9/4
RT Comm.

W11:14/4
Lab6
(Mini6410)

W11:16/4
Lab7
b7
(Mini6410)

W12:21/4
: /
RT Databases

W12:23/4
b
Lab8
(Mini6410)

W13:28/4
Lab9
b
(Mini6410)

W13:30/4
Lab10
b
(Mini6410)

W14:5/5
Lab11
(Mini6410)

W14:7/5
Lab12
(Lab Project)

W15 (W2):12/5
Lab13
(Lab Project)

EE-522

Fi l Exam
Final
E
2/17/2015

Adeel Pasha, LUMS, 2014-15

Features
RISC-based processor
Operating frequency up to (48MHz)*
32-35 GPIOs
3 Timers (T0, T1, T2)
Internal 10-bit ADC
USART
2.0V
2 0V to 55.0V
0V working
ki range+
* 20MHz mentioned in Datasheet
+ Depends on X in18X452
3

EE-522

2/17/2015

Adeel Pasha, LUMS, 2014-15

Compiler
We will be usingg CCS PICC
Built-in RTOS library
Has an extension of cyclic
y scheduler for RT-task schedulingg
Supports multi-tasking and delay functions
Non-preemptive scheduler

User friendly
Built-in functions for I/Os
Support for standard C functions e.g. printf , scanf , etc.

Interaction with hyper-terminals through RS-232 port

EE-522

2/17/2015

Adeel Pasha, LUMS, 2014-15

Example: I/O Functions


output_b(255);

//TurnsallPINSonPortBhigh

output_low(PIN_B5);

//OnlyPIN5ofPortBwillbehigh

output_high(PIN_B4);

//OnlyPIN4ofPortBwillbelow

output_toggle(PIN_B3);

//TogglePIN3ofPortB

input_b();

//TurnsPortBasinputandreturnscomplete
//1byteofdatavaluestoredatPortB

input(PIN_B7);

EE-522

//TurnsPIN7ofPORTBasinputandreturns
//singlebiti.e.1ifitishighelse0

2/17/2015

Adeel Pasha, LUMS, 2014-15

Example: Testing I/O Ports


while(TRUE){
hil (TRUE){
output_b(255);
//turnallpinsofportBON
output_d(255);
//turnallpinsofportBON
y_ms(500);
(
);
//introduceadelayof500ms
//
y f
delay
output_b(0);
//turnallpinsofportBON
output_d(0);
//turnallpinsofportBON
delay_ms(500);
//
//printHelloWorldtooutputdevice(serialport)
i
ll
ld
d i
(
i l
)
printf("HelloWorld\n\r");
}

EE-522

2/17/2015

Adeel Pasha, LUMS, 2014-15

Example: Interrupt Handler in PIC


#INT_XXXX
//definesinterruptroutine
voidXXXX isr(){
voidXXXX_isr(){
[ISRRoutineforInterruptXXXX]
.
.
}
.
.
.
void main(){
.
.
enable_interrupts(INT_XXXX);
//enablesXXXXinterrupt
enable interrupts(GLOBAL);
enable_interrupts(GLOBAL);
//enablesglobalinterr pts
//enablesglobalinterrupts
.
//enablespreviousinterruptstobecomeactive
.
}

EE-522

2/17/2015

Adeel Pasha, LUMS, 2014-15

Softwares Needed
PIC-C Programming Environment
MikroProg Suite for PIC to program the PIC18F452
Hyper Terminal for serial output on Windows
Make sure all of them are installed on the PC where you are

working

If not get it from the TA

Run all those SWs as administrator

Don
Dontt login using your
our ID
ID, use EELAB with
ith Lums12345

EE-522

2/17/2015

Adeel Pasha, LUMS, 2014-15

SWs Needed

EE-522

2/17/2015

LAB-1 Handout

10

EE-522

2/17/2015

Adeel Pasha, LUMS, 2014-15

PICC-RTOS
PICC
RTOS API
# use rtos (options)
timer
ti
minor_cycle
statistics

# task (options)
rate
max

rtos_run()
rtos_terminate()
rtos_enable(task)
rtos_disable(task)
11

EE-522

rtos_stats()
rtos_overrun()
rtos_await
_
((express)
p )
rtos_wait(sem)
rtos signal(sem)
rtos_signal(sem)
rtos_yield ()

2/17/2015

Adeel Pasha, LUMS, 2014-15

Example: Testing I/O Ports using RTOS


#usertos(timer=1,minor_cycle=100ms)
intout;
#task(rate=500ms,max=50ms)
voidLED_Blink(){
out=~out;
output_b(out);
output_d(out);
}
#task(rate=1000ms,max=50ms)
voidSERIAL_Write(){
printf("HelloWorld\n\r");
}

12

EE-522

voidmain()
{
out=0xFF;
rtos_run();
sleep();
}

2/17/2015

Adeel Pasha, LUMS, 2014-15

PICC-RTOS
PICC
RTOS Scheduler Semantics

13

EE-522

2/17/2015

LAB-1 Handout

14

EE-522

2/17/2015

Quiz Time

15

EE-522

2/17/2015

You might also like