• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RTOS for a 18F1320

Status
Not open for further replies.

GreenP

New Member
Hi
Could anyone please help me with the basic understanding of RTOS implemented in C, which incorporates a single interrupt routine at regular frequent time intervals, as I am struggling with the basic concept in the C language.

Thanks GreenP
 

3v0

Coop Build Coordinator
Forum Supporter
I have good feedback on this cooperative multasking tutorial. You may be looking for time-slice which is very difficult to do on a uC. In any case this will teach you about non blocking IO and delays.

BoostC - C18 Tutorials : Cooperative Multitasking

Table of Contents
Introduction
What you must know
What you will need
Definitons
Sequential Execution
Cooperative Multitasking
NAOS Tasks
Finite State Machines
It's All About Timing
Multitasking = Tasks + Timing
kTimer's Math
A Second Task
Apendix A: Source Code
DJ_coop2.c
multiCompiler.h
Apendix B: Hardware​
3v0
 

GreenP

New Member
Thanks for the reply blueroomelectronics

What I am attempting to do is build a single digit calculator which I have working besides the clear button which should have a frequent share of the CPU. OK I could constantly poll the button, but I would prefer to implement it using a real time system.

Thanks
 

GreenP

New Member
Thanks felis

But I am using a 4*4 matrix keypad so this would be difficult, anyway I would like to get my head around an interrupt routine.

Thanks
 

GreenP

New Member
I have a 4*4 matrix keypad connected to portB and a sevensegment display connected to portA, therefore using all the pins.
 

GreenP

New Member
If I make use of TMR1 for two seperate timming intervals so that the routine checking the status of the clear button and the other performing the other functions, what interrupt flags are set, and how is it possible for the routine running at the time to see that interrupt flag and subsequently return to the code implementing the timmed interrupts?

GreenP
 

felis

New Member
I agree. But I am not sure it would buy him much more then polling.
You don't need to poll. You can make this calculator with two interrupt routines and one state machine. A keyboard is connected to port b, rows to lower half, columns to upper. One interrupt is triggered by timer and scans the next row. Another one is triggered by change of portb4-7 and changes the value of state machine state variable.
 

Pommie

Well-Known Member
Most Helpful Member
There is no need for an RTOS and the only interrupt I would implement would be for multiplexing a display (not required in this case) and for timing purposes. I would simply read the keyboard every 10mS and execute the required code. Why would any key require priority? The code execution should be faster than you can press keys and so the Clear button should get acted upon immediately.

Mike.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
There is no need for an RTOS and the only interrupt I would implement would be for multiplexing a display (not required in this case) and for timing purposes. I would simply read the keyboard every 10mS and execute the required code. Why would any key require priority? The code execution should be faster than you can press keys and so the Clear button should get acted upon immediately.
I agree with Pommie, there's no reason to want an RTOS for such a simple project (and probably hardly ever any need anyway), simply poll the keyboard and it will be far faster than you could possibly require.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top