avatarJ3

Summary

The webpage provides a comprehensive guide to setting up and running a Real-Time Operating System (RTOS) called OSA on Microchip PIC microcontrollers, specifically using the PIC18F4522 or PIC18F45K22 chips with tools like MikroC PRO for PIC, EasyPIC 7, and PICkit 2.

Abstract

The article is the second part of a three-part series that serves as a quick introduction to implementing an OSA/RTOS on Microchip PIC microcontrollers. It guides the reader through the process of obtaining and configuring the necessary software, including the RTOS-OSA code from the official OSA website, OSAcfg_Tool for configuration, and MikroC PRO for PIC as the development environment. The tutorial also covers the hardware requirements, such as the PIC18F4522 or PIC18F45K22 chips, and the use of the PICkit 2 programmer/debugger or MikroElektronika's mikroProg Suite for PIC. The author provides step-by-step instructions, including screenshots and a video, to help the reader build a project that flashes three LEDs using different threads, demonstrating the capabilities of the RTOS. The guide aims to help readers replicate the project and understand RTOS concepts through practical application.

Opinions

  • The author emphasizes the ease of portability of the OSA/RTOS code to different Microchip PIC microcontrollers, including the PIC18F4522 and PIC18F45K22.
  • The use of the OSAcfg_Tool is highlighted as a crucial step in the configuration process, with troubleshooting tips provided for issues with registering the MSFLXGRD.OCX module on Windows 10.
  • The author suggests that readers should have administrator access to successfully execute certain commands and register necessary files.
  • The article promotes the MikroC PRO for PIC compiler and the PICkit 2 programmer as recommended tools for the development process.
  • The inclusion of a video and detailed screenshots indicates the author's commitment to providing clear and visual aids for the reader's understanding.
  • The author expresses anticipation of the reader's success in replicating the project and encourages them with a congratulatory note, indicating a supportive and educational tone.

OSA / RTOS — Quick Intro — Part 2/3

Real-Time Operating System for Microchip PIC-controllers

Hi guys! See Part 1 too!

We’re back, now with a working OSA/RTOS code (github repo👈).

We’ll use a PIC18F4522 chip from PicGenios board.

PICGenios 18F

The board is from Microgenios, a Brazil’s firm Microchip’s Certified Trainning Partner, where I took my specialization course in pic.

You can also use PIC18F45K22 chip from EasyPIC™ 7. It is the latest version of this popular development tool from MikroElektronika (MIKROE-798). Now with dual power supplies (3.3V and 5V) it supports over 250 different PIC MCUs. EasyPIC 7 accepts DIP packages from 8 to 40 pins and comes with a PIC18F45K22 installed.

In every bsp.c code there is this block, which makes it portable to EasyPIC™ 7:

ifdef P18F45K22
      (…)
#else
       (…)//P18F4522
#endif

Lets get started!

The idea is to flash 3 LEDs simultaneously on different threads (tasks).

Step-by-Step:

  • Step 4 →Now we need OSAcfg_tools.

Do this: In the same place, below TOOLS tab, get the osa:osacfg_tools.rar, Program File, for manual installation; Cool…

  • Step 5 →Unrar it. When you try to run the OSAcfg_Tool.exe app as administrator (and I’m using Windows 10) you’ll get this error:-(
Failed to load MSFLXGRD.OCX module

The problem is that windows does not find the way to register this file. Do just that :

a) copy …\osacfg_tool\OSAcfg_Tool folder to c:/ folder;

b)on OSAcfg_Tool directory open readme.txt and you’ll read it:

Before running OSAcfg_Tool.exe, run install.bat to register the .ocx file

c) see inside install.bat (use notePad) this:

regsvr32 MSFLXGRD.OCX

d) and you’ll have to execute this command on prompter.exe (as admin) like this on c:/ folder:

regsvr32 C:\OSAcfg_Tool\MSFLXGRD.OCX

Please, note that you’ll need a administrator access!

You’ll will see this message (sort of:)

DllRegisterServer in C:\OSAcfg_Tool\MSFLXGRD.OCX was successful

Now run OSAcfg_Tool.exe and you’ll see:-)

  • Step 6 →Now copy the osa folder from osa_110306\osa to your \code directory with this layout:

We added the directory apps where we will save all our OSA/RTO future projects.

See that we will use the OSAcfg.h for each project (so in this project, it is a barebone file);

  • Step 7 → Now go to MikroElectronika web page mikroC compilers and chose mikroC PRO for PIC (in these days Release version: 7.1.0);
  • Step 8 → Run this app and you’ll get this on your desktop:
MikroC Pro For PIC
PicKit2
  • Step 11 → Build your directories. See this video sequence for your reference. These are the tasks executed here:

a)Make a directory and name it code;

b)Copy/paste osa_110306\osa folder to it;

c)Leave kernel, Port folders and others files that are on base folder, including osa.c and osa.h (see above image dir layout) ;

d)Create apps folders;

e)Inside this folder create First_OSA_Project folder;

f)On code base create osacfg_tool folder and copy/paste all OSAcfg_Tool folder into it;

g)Open MikroC Pro For PIC and run a new project;

h)Project > Close Project (to safeguard);

i)New Project — Stardard and next;

j)Point to your new directory base;

l)Chose P18F4520 (or P18FK4520 for EasyPIC™ 7), 8 MHz;

m)next, next;

n)Copy/Paste this code:

o)Open OSAcfg_Tool and set

OS_TASKS = 3
OS_ENABLE_TIMER

p)In Project Manager include these files(Add Existing File…)

osa.c -> Source osa.h OSAcfg.h -> Header Files

q)compile (build) the code;

r)Run PicKit2 and load .hex file to the chip (if you’re using EasyPIC™ 7 run mikroProg Suite For PIC);

s)There you have it!

In the video you’ll see some comments about this code. This is issue for future Pic Interruptions Series videos.

Thanks & Congrats! (if you succeed to replicate it:-)

Download All Files For This Project

Credits & References:

PART 1PART 2 — PART 3

http://www.microgenios.com.br

So you made it so that, in order to fly, you need a certain amount of flat terrain.

— — — — — —

First Published @ Nov,2017

Rtos
Embedded Systems
Roses
Mikroc Pro For Pic
Operation Systems
Recommended from ReadMedium