Full Version : My own kernel for atmega microcontrollers :D
avr >>PROJECTS (AVR) >>My own kernel for atmega microcontrollers :D


morgoth- 07-07-2008
My own kernel for atmega microcontrollers :D

This project is a kernel initially made for Atmega 64

In process to update( modify for unlimited number of thread openned )
For moment the kernel is designed to run an predefined maxim number of threads


Description:
- This kernel was designed to use all the processing power of an microcontroller, in the case when on a device are used more microcontrollers each one with different functions and they (microcontrollers) don't work at maximum capacity, and it can facilitate tremendously the job of an programator who wants to implement more functions in only one microcontroller.

- On this kernel, more programs totally independently can work simultaneously (in the same time), the only thing that is affect is the processing power on each one.

- This programs can communicate between them using the unique ID of the program, so if we update a program or a driver, it will replace the old one with the new one without actualizing the remaining programs (the programs who were not updated) to the new address of the new program, the address of new program is declared in the installed programs table.

- When a program starts to run the kernel reads from the program haw much memory ram to give him, the kernel assigns to the program the memory ram demanded rounded of form 64 in 64 octets (if a program needs 0 (zero) memory ram the kernel will not assign ram memory to that program; if a program needs 1-63 bytes memory ram the kernel will assign 64 octets ram memory to that program; if a program needs 64-127 bytes memory ram the kernel will assign 128 octets ram memory to that program) but when the program is running it can change the dimension of the memory ram assigned, according to the memory ram he needs, by "handing in an application" to the kernel demanding a change of memory ram assigned.

- If a program requests to the kernel to open a program the kernel can open it, the kernel is checking if that program is already open, if that program is open, the kernel reads if that program can be open again, if it can be open again it will be open like a new thread independently from the previous and it will give a order number (the first open program will have the number of order 0 (zero), the second program open will have the number of order 1 etc.) this value it will be return to the program who requested the open to the program to make the difference between the open threads with the same ID. If the requested program can't be open many times, the program who demanded the open of the program will receive an error the program can't be open because is already open. (This function is incomplete implemented.)

- At the end of a program, the kernel is taking care of deleting the cluster of memory ram occupied by the program (the memory ram that this program occupied can be used by future open program) and immediately the kernel will compact the table in which are kept the principals dates of each open program.

- A program can be force closed by the kernel if there is an stack overflow error, the program can request the kernel to be closed or the kernel receive the close command from another program, and the program who will be closed can save the working dates and after that sending the close command to the kernel.

- The open programs divide the processing power equally, but there is the case when a program is in idle, in this case the program will sent to the kernel a interrupt command the processing power remain between the time when the demand of interrupt and the time of interrupt is equally divided to the running programs.

- For each program the kernel assigns an cluster of memory ram of 64 octets because when the program is interrupted the kernel to save 32 registry, stak counter and 30 octets from the stak occupied by the program, before returning in the interrupted program the kernel will restore the contents of 32 registry the stak and counter of the stak.

- The memory ram for each program begins from an virtual address 0 (zero) in the registry Z where is the address of the head cluster of the memory ram assigned, if a program wants to find out the address of the head cluster memory ram assigned it can appeal a routine from the kernel to give him the address (in this way, using an artifice we can use the direct address knowing that the cluster memory ram used starts at the head address +2).

- System Timers: They were integrated to can make data processing and to an exact time and for software pause in lock delays, system timer have 128 steps/sec, so we can create software with the exact time of the external Quartz of 32768Hz. A program can have maxim 9 system timers (each timer occupied 6 octets from the assigned memory ram) and they can be formed only in the first cluster of memory ram assigned.( In future i want to make the module to use an unlimited number of timers per thread )

(Still working at kernel.)

I've only adapted 3 drivers for this kernel.

This kernel can be adapted on any microcontroller ATmega with the some little modifications.
_______________________________________________________________________________________________________________________________________
Status:
------General status: - still working on it.
---------------The modulus for multitasking: Finish.
---------------The modulus for launch program: Finish.
---------------The modulus for startup: Finish.
---------------The modulus for assign memory ram: Finish.
---------------The modulus for free memory ram assigned at the close of a program: Finish.
---------------The modulus for modify memory ram assigned to a program: Finish.
---------------The modulus for sending commands to open programs: Finish.
-----------------------Demands for appeal:
-------------------------------In R17: The number of command to be send.
-------------------------------In X: The program ID which the command will be sent.
---------------------------------------Sent data can't be in registry:
R17,XI:Xh and YI:Yh (In YI:Yh is returned the address of the first cluster of memory ram assign to the program which the command will be sent).
---------------The modulus for write/read in/from memory ram: Finish.
---------------The modulus Filesysytem internal EEPROM: Coming up soon!
---------------The modulus for auto-detect memory ram size connected to the microcontroller: Coming up soon!
---------------The modulus for monitoring memory ram size assigned: Coming up soon!
---------------The modulus for monitoring processing power occupied at one moment: Coming up soon!
---------------The modulus for installing programs and libs via Uart0: Finish - not tested yet.
---------------The modulus for uninstalling programs and libs via Uart0: Finish - not tested yet.
---------------The modulus for system timers: Finish.
-------Included Functions:
---------------Setuptimer = In R16 - timer number, R17:R18 - the value of timer (128 = 1 second).
---------------TimerEnabledTrue = In R16 timer number.
---------------TimerEnabledFalse = In R16 timer number.
---------------VerifyTimmerForTik = In R16 timer number, if there is tik jumps over the call instruction of the verify routine.
---------------Ex:
-----------------------Ldi R16,0
-----------------------Call VerifyTimerForTik
-----------------------Rjump Tik
-----------------------Rjump NoTik
Secondary Modulus:
--------Display driver for Nokia3310:Finish.
------------------------Included functions:
-------------------------------ClearLcdDisplay
-------------------------------WriteOneCharDisplay
-------------------------------NextRowDisplay
-------------------------------WriteOneCharWithAdressDisplay
-------------------------------PrintImageDisplay
-------------------------------BlackLcdDisplay
-------------------------------PrintOneLineDisplay

System lib for Uart0 Uart1: Finish. (This lib is special made to appeal 3 functions of the program which runs with this lib).
-------------------------------Uart0ComandByteReceived
-------------------------------Uart0ComandUdreEmpty
-------------------------------Uart0ComandTransmitComplete
-------------------------------Uart1ComandByteReceived
-------------------------------Uart1ComandUdreEmpty
-------------------------------Uart1ComandTransmitComplete
Included functions:
-----------------------Uart0:
---------------------------------------------WriteNameProgramForUart0; In R16:R17 program's name which Uart0 will work (if Uart0 is busy, it will return R16=255)
---------------------------------------FreeUart0;Free Uart0
---------------------------------------Uart0Baut;In R16:R17 registry value UBRR0L and UBRR0L
---------------------------------------Uart0StopBits;In R16=1 a stop byte, R16=2 two stop bytes
---------------------------------------Uart0Parity;In R16=0 without parity, R16=1 Odd parity, R16=2 Even parity
---------------------------------------Uart0SincAsinc;In R16=0 Uart0 in asynchrony mode, R16=1 Uart0 in synchrony mode
---------------------------------------Uart0RisingFalingClk;In R16=0 if Uart0 is in synchrony mode then the clock's front it will be in Rising, R16=1 in Falling
---------------------------------------Uart0BitsNumber;In R16=5 Bytes R16=6 Bytes, R16=7 Bytes, R16=8 Bytes, R16= 9Bytes
---------------------------------------Uart0EnableDisable;In R16=0 Tx-Rx Disabled, R16=1 Tx Enabled, R16=2 Rx Enabled, R16=3 Tx-Rx Enabled
---------------------------------------Uart0Interupts;In R16=1< -------------------------------Uart1:
---------------------------------------WriteNameProgramForUart1;In R16:R17 program's name which Uart1 will work (if Uart0 is busy, it will return R16=255)
---------------------------------------FreeUart1;Free Uart1
---------------------------------------Uart1Baut;In R16:R17 registry value UBRR1L and UBRR1L
---------------------------------------Uart1StopBits;In R16=1 a stop byte,R16=2 two stop bytes
---------------------------------------Uart1Parity;In R16=0 without parity, R16=1 Odd parity, R16=2 Even parity
---------------------------------------Uart1SincAsinc;In R16=0 Uart1 in asynchrony mode, R16=1 Uart1 in synchrony mode
---------------------------------------Uart1RisingFalingClk;In R16=0 if Uart1 is in synchrony mode then the clock's front it will be in Rising, R16=1 in Falling
---------------------------------------Uart1BitsNumber; In R16=5 Bytes R16=6 Bytes, R16=7 Bytes, R16=8 Bytes, R16= 9Bytes
---------------------------------------Uart1EnableDisable;In R16=0 Tx-Rx Disabled, R16=1 Tx Enabled, R16=2 Rx Enabled, R16=3 Tx-Rx Enabled
---------------------------------------Uart1Interupts;In R16=1<
The lib for external FileSystemEEprom: Coming up soon!

The lib FileSystemFlashCard: Coming up soon! - I've only done the driver "for working" with flash chip.
--------Included functions:
-------------------------------ReadFromFlashWithAdress
-------------------------------ReadByteFromFlash
-------------------------------WriteToFlashWithAdress
-------------------------------WriteByteToFlash
-------------------------------WriteEndDataToFlash
-------------------------------BlokEraseFromFlash
-------------------------------ReadIdFromFlash
-------------------------------ReadStatusRegister
-------------------------------CopyBackFlashMemory

Driver for ESD Bluetooth: Coming up soon!
Driver for modulus GSM GM862: Coming up soon!

Oficial page for project

For moment is in prototype stage :D


Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.