Jump to content

Exploring MIOS...


lemonhorse
 Share

Recommended Posts

Hi *!

I want to get on with my MIDIBOX skills - someday I hope to find a way for Interfacing the AY-3-8912 Soundchip via MBHP, MIOS and Assembler.

ay38912chip.jpg

=> http://en.wikipedia.org/wiki/AY-3-8912

My "MidiBox AY" (prototype) [just a MidiBoxKB and an MIDImon with no AY-3-8912 interface yet]

lemlab200707a.jpg

related => http://www.midibox.org/dokuwiki/doku.php?id=midiboxkb_-_using_a_c64_keyboard_as_input

related => http://www.midibox.org/dokuwiki/midibox_pokey

I never did programming in Assembler yet. But I want to! :)

So I'm thrilled to explore the PIC 18F452, Assembler and MIOS - step by step.

Here my first beginner question:

-----------------------------------------------------------------------------

THE MIOS MEMORY MAP

mios19pic18f452ram.jpg

Is this sketch ok?

Link to comment
Share on other sites

Thats a good starting point! :)

Note that 0x000..0x002 is reserved for MIOS internal variables, and 0x03..0x0f is allocated by MIOS_PARAMETER[123], TMP[12345] and IRQ_TMP[12345]

So, free application space starts at 0x010

Best Regards, Thorsten.

Link to comment
Share on other sites

MIOS is a text adventure 

yes, it is! ;)

next step: exploring the application-code...

MIOS - the MIDIbox Operating System [http://www.ucapps.de/mios_download.html]

=> skeleton_v1_9

...my speculations about mios.h


;; ==========================================================================
;;  MIOS Special Function Registers
;; ==========================================================================

MIOS_BOX_CFG0	EQU	0x000
MIOS_BOX_CFG1	EQU	0x001
MIOS_BOX_STAT	EQU	0x002
MIOS_PARAMETER1	EQU    0x003
MIOS_PARAMETER2	EQU	0x004
MIOS_PARAMETER3	EQU	0x005

;; ==========================================================================
;;  temporary registers for main programs
;; ==========================================================================
TMP1		EQU	0x006
TMP2		EQU	0x007
TMP3		EQU	0x008
TMP4		EQU	0x009
TMP5		EQU	0x00a

;; ==========================================================================
;;  temporary registers for IRQs
;; ==========================================================================
IRQ_TMP1	EQU	0x00b
IRQ_TMP2	EQU	0x00c
IRQ_TMP3	EQU	0x00d
IRQ_TMP4	EQU	0x00e
IRQ_TMP5	EQU	0x00f

;; ==========================================================================
;;  free memory space for user application:
;; ==========================================================================
;; 0x010-0x37f

no problem so far...
;; ==========================================================================
;;  General constants
;; ==========================================================================

;; used by MIOS_MIDI_Interface*
MIOS_MIDI_INTERFACE_COMMON	EQU	0x00
MIOS_MIDI_INTERFACE_TO_HOST	EQU	0x01

;; used by MIOS_MIDI_Merger*
MIOS_MIDI_MERGER_DISABLED	EQU	0x00
MIOS_MIDI_MERGER_ENABLED	EQU	0x01
MIOS_MIDI_MERGER_MBLINK_EP	EQU	0x02
MIOS_MIDI_MERGER_MBLINK_FP	EQU	0x03

;; used by MIOS_ENC_PIN_TABLE
MIOS_ENC_MODE_NON_DETENTED	EQU	0x00
MIOS_ENC_MODE_DETENTED		   EQU	   0x80
MIOS_ENC_MODE_DETENTED2	           EQU	  0x81

;; used by MIOS_ENC_Speed*
MIOS_ENC_SPEED_SLOW		 EQU	 0
MIOS_ENC_SPEED_NORMAL		EQU	1
MIOS_ENC_SPEED_FAST		  EQU	  2

;; used by MIOS_LCD_Type*
MIOS_LCD_TYPE_CLCD		EQU	0x00
MIOS_LCD_TYPE_GLCD0		EQU	0x01
MIOS_LCD_TYPE_GLCD1		EQU	0x02
MIOS_LCD_TYPE_GLCD2		EQU	0x03
MIOS_LCD_TYPE_GLCD3		EQU	0x04
MIOS_LCD_TYPE_GLCD4		EQU	0x05
MIOS_LCD_TYPE_MLCD		EQU	0x06
MIOS_LCD_TYPE_GLCD_CUSTOM  EQU	  0x07

but...

MIOS_MIDI_INTERFACE_COMMON  EQU  0x00  => [Location: ?]

MIOS_ENC_MODE_DETENTED EQU   0x80 => [Location: ?]

MIOS_ENC_MODE_DETENTED2  EQU   0x81 => [Location: ?]

MIOS_ENC_SPEED_SLOW  EQU  0 => [Location: ?... ]

MIOS_GLCD_FONT EQU 0x7cfc => [Location: ?... ]

speculations ::) :

MIOS_BOX_CFG0 EQU 0x000 is a DATA RAM address assignment - right?

Is MIOS_ENC_SPEED_SLOW  EQU 0 and

MIOS_ENC_MODE_DETENTED2 EQU 0x81 a DATA RAM byte-content assignment? [somewhere within the MIOS DATA RAM area?]

Is MIOS_GLCD_FONT EQU 0x7cfc a PROGRAM MEMORY address assignment?

Link to comment
Share on other sites

In general it has to be considered, that constant definitions (EQU) can either be addresses or just values which are used for different purposes. The assembler doesn't make a difference here.

In distance to "#define", which you will also find sometimes in my applications, an EQU statement makes the definition public over the whole code. The assembler will replace the name by the constant definition during a second pass.

A #define statement works only "below" the statement - therefore I'm only using it when I'm sure that it is defined early enough (inconsistently)

MIOS_BOX_CFG0: yes, an address in data RAM

MIOS_ENC_SPEED*: these are values which are used in mios_tables.inc (encoder speed modes)

MIOS_GLCD_FONT: yes, thats an address in program memory

Best Regards, Thorsten.

Link to comment
Share on other sites

Sorry TK,

I don't want to steal your precious time with basic assembler-questions  ;)

So perhaps I should read this first:

MPASM Assembler Overview: MPASM™ Assembler, MPLINK™ Object Linker, MPLIB™ Object Librarian User’s Guide

http://ww1.microchip.com/downloads/en/DeviceDoc/33014J.pdf

PIC18FXX2 - Data Sheet:

http://ww1.microchip.com/downloads/en/DeviceDoc/39564c.pdf

Are there other usefull resources in this context ?

Best Regards,

- Lemonhorse

Link to comment
Share on other sites

TK:

MIOS & Applications Re-Released for GPUTILS

« on: 20.01.2008 at 16:33 »

In order to get rid of the windows propritary MPASM assembler, I started to migrate MIOS and most of the applications to the GPUTILS toolchain. This freeware is available for all major operating systems (including Windows/Linux/Mac OS), and therefore should allow everbody to customize and rebuild an application without Windows installation.

[...]

http://www.midibox.org/forum/index.php/topic,10552.msg80333.html#msg80333

He he - I'll never will keep step with You TK!  ;)

I'm absolutely happy about the GPUTILS adoption - because now I can carry out my MIOS experiments on Linux!  :D

But - is there a chance that:

http://www.ucapps.de/mios/sm_example1_v2.zip +

http://www.ucapps.de/mios/sm_example2_v1.zip

will be merged to GPUTILS compatibility? (now the code is just MPASM compatible right?)

Link to comment
Share on other sites

The direct execution of "gpasm" is not recommented, instead just type "make" to process the Makefile.

There are some applications, which got additional parameters in this file.

Another point is, that I'm planning to change the file structure of applications soon (uniformed structure, hostet on a SVN server, include files like "mios.h" or "mios_vectors.inc" won't be located in the application main directory anymore)

So, please wait a little bit with such docs, they will be expired once the update has been done.

Best Regards, Thorsten.

Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...

To confirm, is this a good concise statement of the data RAM usage:

	;; Data memory layout	(Data RAM)
	;; 0x000-0x00f	reserved memory for MIOS
	;; 0x010-0x37f	free memory for user applications
	;; 0x380-0x5ff	reserved memory for MIOS
	;; 0x600-0xf7f	free memory for user applications on 18F4620
	;; 0xf80-0xfff	special function registers (SFR)

Link to comment
Share on other sites

Yes, it's correct for PIC18F452 and PIC18F4620, but not for PIC18F4685, where 0x60..0x7f and 0xd00..0xf7f are reserved for the ECAN peripheral.

Under

http://svnmios.midibox.org/listing.php?repname=svn.mios&path=%2Ftrunk%2Fetc%2Flkr%2F

you will find linker scripts which contain a complete list of available memory locations

These scripts are automatically selected by the Makefile mechaisms when compiling C programs.

Best Regards, Thorsten.

Link to comment
Share on other sites

  • 4 months later...

// $Id: p18f452.lkr 298 2008-04-26 21:04:02Z stryd_one $

// linker script for a MIOS project:


... 
CODEPAGE   NAME=vectors    START=0x2C00         END=0x2FFF         PROTECTED
CODEPAGE   NAME=page       START=0x3000          END=0x7FFF
...

Does it [sTART=0x3000 END=0x7FFF] imply:

PROGRAMM MEMORY SPACE for USER APPLICATION (18f452)

[HEX BYTES = 0x4FFF] / [DEC. BYTES = 20.479] ==> [WORDS = 10.239] ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...