Micriµm
µC/OS-II for Atmel AVR (ATmega128)
Table Of Contents
1.00 Introduction 4
1.01 Atmel AT90 (AVR) 6
1.02 Test Setup 8
1.03 Development Tools 9
2.00
Directories and Files 12
3.00
µC/OS-II Port Files 14
3.01 OS_CPU.H 14
3.01.01 OS_CPU.H, macros for ‘externals’ 14
3.02.02 OS_CPU.H, Data Types 15
3.01.03 OS_CPU.H, Critical Sections 15
3.01.04 OS_CPU.H, Stack growth 16
3.01.05 OS_CPU.H, Task Level Context Switch 16
3.01.06 OS_CPU.H, Global Variables 16
3.02.07 OS_CPU.H, Function Prototypes 17
3.02 OS_CPU_C.C 18
3.02.01 OS_CPU_C.C, OSTaskCreateHook() 19
3.02.02 OS_CPU_C.C, OSTaskStkInit() 19
3.02.03 OS_CPU_C.C, OSTaskSwHook() 24
3.02.04 OS_CPU_C.C, OSTimeTickHook() 24
3.03 OS_CPU_A.S90 (IAR), OS_CPU_A.S (ICC) 25
3.03.01 OS_CPU_SR_Save() 25
3.03.02 OS_CPU_SR_Restore() 25
3.03.03 OSStartHighRdy() 26
3.03.04 OSCtxSw() 29
3.03.05 OSIntCtxSw() 32
3.04 OS_CPU_I.S90 (IAR), OS_CPU_I.H (ICC) 33
3.05 OS_DBG.C 33
4.00
µC/OS-View Port 34
4.01 µC/OS-View Port Files 35
4.02 OS_VIEWc.h 36
4.03 OS_VIEWc.c 36
4.04 OS_VIEWa.s90 (IAR) or OS_VIEW_a.s (ICC) 37
5.00
Application code 38
5.01 app.c 38
5.01.01 Creating a task with OSTaskCreate() 41
5.01.02 Creating a task with OSTaskCreateExt() 41
5.02 app_cfg.h 42
5.03 app_isr.s90 (IAR), app_isr.s (ICC) 43
5.04 app_vect.s90 (IAR), app_vect.s (ICC) 45
5.05 includes.h 46
5.06 os_cfg.h 46
2
Micriµm
µC/OS-II for Atmel AVR (ATmega128)
1.00 Introduction 1.00 Introduction
This application note describes the µC/OS-II port for the ATmega128. However, the information
provided in this application note should be portable to other processors in the AVR line.
We tested the port on an Atmel STK500/501 development board (see Figure 1-1) using an Atmel
JTAGICE mkII (see Figure 1-2). The processor is assumed to run at 8 MHz using the on-chip
oscillator. The example code changes the prescaler to divide by 1 from the factory default of
divide by 8.
We assume that you have µC/OS-II V2.80 (or higher) and optionally, µC/OS-View V1.30 (or
higher). If you didn’t purchase µC/OS-View from Micriµm you can still run the example code by
disabling invocations to that code.
We tested the code using two different sets of tools:
IAR’s EWAVR (
www.IAR.com)
ImageCraft’s ICCAVR (
www.ImageCraft.com)
UART0
to RS232 SPARE
(PortE: B0 = RxD0, B1 = TxD0)
J-Ta
g
STK500
STK501
PortD connected to LEDs RS-232C fo
r
µ
C/OS-View
Figure 1-1, Atmel STK500/501 Setup for testing µC/OS-II and µC/OS-View
4
Micriµm
µC/OS-II for Atmel AVR (ATmega128)
Atmel’s JTAGICE mkII
RS-232C connected to Desktop (COM1)
&
µC/OS-View
USB connected to Desktop
&
AVR Studio 4
Figure 1-2, Atmel’s JTAGICE mkII
5
评论0