Header file for M32C/M16C

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi all,

I'm seeking about header C file for M32C/M16C internal ressources (UART's,
SSC, SPI, ... etc registers definition).
I guess there are some common reg and bits definition over M32C/M16C
family.

Thx, Habib.

Re: Header file for M32C/M16C
On 11D4%C216C8%D5, CF%C2CE%E76CA%B121B7%D6, Habib Bouaziz-Viallet <ha.=
..@mizar.systems> wrote:
Quoted text here. Click to load it

The header C file may be availabe for some IDEs such as Codeworrior,
check it. :)

tcysb    http:www.info-life.cn

Re: Header file for M32C/M16C
Le Fri, 16 Nov 2007 17:13:31 -0800, yusibin a écrit:

wrote:
Quoted text here. Click to load it
I have no IDE nor Codeworrior. I always use emacs and make :-) and i'm
quite sure it's sufficent to build good software.

M32C/M16C register map is quite big, can you show me some header file in
relation with ?

Thx, Habib.


Quoted text here. Click to load it

Re: Header file for M32C/M16C
Quoted text here. Click to load it

For which compiler?

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.
Re: Header file for M32C/M16C
Le Sun, 18 Nov 2007 12:44:42 +0000, Chris Hills a écrit:

Quoted text here. Click to load it
Hi !
Quoted text here. Click to load it
IIs the choice of the compiler is important ? I think not. So i'm using gcc
(m32-elf-..).
Quoted text here. Click to load it
Habib.

Re: Header file for M32C/M16C
Quoted text here. Click to load it

Yes.


Then you would be wrong.

Quoted text here. Click to load it


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.
Re: Header file for M32C/M16C
Quoted text here. Click to load it

Not if the header is written in standard C and leaves the weird
translation and manipulation to the system sensitive .c file.

--
 Chuck F (cbfalconer at maineline dot net)
   <http://cbfalconer.home.att.net
We've slightly trimmed the long signature. Click to see the full one.
Re: Header file for M32C/M16C
CBFalconer a crit :
Quoted text here. Click to load it

The Perl Script (Many thanks to M. DJ Delorie) works fine ! Just make
./mkport.pl < reg_m16 and magically this script build a rm16c_port.h
(and also an ASM file) !!

Great Job indeed !!

Habib

Re: Header file for M32C/M16C
Quoted text here. Click to load it

No such thing as "standard C" when referring to header files for
hardware registers.  Most compiler vendors have different ways of doing
them

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.
Re: Header file for M32C/M16C

Quoted text here. Click to load it

Somewhat.  N30 has a special syntax for saying "this variable lives at
this specific location in memory" that gcc doesn't support.  GCC uses
linker tricks to do the equivalent, although it's possible to write a
perl script that converts one to the other.  However, I'm attaching a
simpler perl script I use to manually enter the I/O definitions
myself, and a sample (r8c-1b) definitions file.  Run on on the other,
it creates a stand-alone .h (for C source) and a usable .S (for ASM
sources).

-------------------- mkports --------------------
#!/usr/bin/perl
# -*- perl -*-

open(S, ">r8c-ports.S");
open(H, ">r8c-ports.h");

print H "typedef unsigned char byte;\n\n";
print H "typedef unsigned short word;\n\n";

while (<>) {
    s/\#.*//;
    s/[\r\n]+$//;

    ($name, $addr, $bits) = split(' ', $_, 3);
    next unless $name =~ /\S/;

    $type = "byte";

    if ($bits =~ /^\.HI\s*(.*)/) {
    $type = "word";
    $bits = $1;
    }

    if ($bits) {
    print S "\n";
    print H "\n";
    $nl = "\n";
    } else {
    print S $nl;
    print H $nl;
    $nl = '';
    }
    print S "$name\t= 0x$addr\n";

    if ($bits) {
    $bitf = 0;
    $unspec = 0;
    $type = "$_type";
    print H "typedef union {\n";
    print H "  struct {\n";
    $sbits = '';
    for $field (reverse split(' ', $bits)) {
        if ($field eq ":") {
        print H "    byte unspec_$unspec:1;\n";
        $unspec ++;
        $bitf ++;
        } elsif ($field =~ /(.*):(\d)/) {
        print H "    byte $1:$2;\n";
        printf S " $_$1\t= 0x%02x\n", ((1 << $2) - 1) << $bitf;
        $bitf += $2;
        } else {
        print H "    byte $field:1;\n";
        printf S " $_$field\t= 0x%02x\n", 1 << $bitf;
        $sbits .= sprintf " _$field\t= %d\n", $bitf;
        $bitf ++;
        }
    }
    print S $sbits;
    print H "  };\n";
    print H "  byte b;\n";
    print H "} $type;\n";
    }

    print H "#define $name (*(volatile $type *)0x$addr)\n";
}
-------------------- r8c-ports.def --------------------
pd0    e2
pd1    e3
pd3    e7
pd4    ea
p0    e0
p1    e1
p3    e5
p4    e8

drr    fe

prcr    0a    : : : : prc3 prc2 prc1 prc0

pm0    04    : : : : pm03 : : :
pm1    05    : : : : : pm12 : :
cm0    06
cm1    07
ocd    0c

iccr1    b8    ice rcvd mst trs cks:4
iccr2    b9    bbsy scp sdao sdaop sclo : iicrst :
icmr    ba    mls wait : : bcwp bc:3
icier    bb    tie teit rie makie stie acke ackbr ackbt
icsr    bc    tdre tend rdrf nackf stop al aas adz

# CPU control

sar    bd    : : : : : : : fsb
icdrt    be
icdrr    bf

pinsr1    f5    : : : : : : uart1sel:2
pinsr2    f6    : trb0sel0 : : : : : :
pinsr3    f7    : : : trciodsel trciocsel : :
pmr    f8    iicsel txd2en txd2sel u2pinsel ssesel : : int1sel

# interrupt control

inten    f9    int3pl int3en : : int1pl int1en int0pl int0en
intf    fa    int3f:2 : : int1f:2 int0f:2

kupic    4d
adic    4e
ssuaic    4f
iic2aic    4f # i2c
cmp1ic    50
s0tic    51 # serial 0 transmit
s1tic    53 # serial 1 transmit
s0ric    52 # serial 0 receive
s1ric    54 # serial 1 receive
txic    56 # Timer X
traic    56 # Timer A
tzic    58 # Timer Z
trbic    58 # Timer B
int1ic    59
int3ic    5a
tcic    5b # Timer C
cmp0ic    5c
int0ic    5d

# UARTs

u0mr    a0    : prye pry stps ckdir smd:3
u0brg    a1
u0tb    a2
u0c0    a4    uform ckpol nch : txept : clk:2
u0c1    a5    : : : : ri re ti te
u0rb    a6    .HI

u1mr    a8    : prye pry stps ckdir smd:3
u1brg    a9
u1tb    aa
u1c0    ac    uform ckpol nch : txept : clk:2
u1c1    ad    : : : : ri re ti te
u1rb    ae    .HI

ucon    b0    cntrsel : u1sel:2 : u0rrm u1irs u0irs

# Timer X (r8x-1b)

txmr    8b    txund txedg txmod2 txocnt txs r0edg txmod:2
prex    8c
tx    8d

# Timer Z (r8c-1b)

tzmr    80    tzs tzwc tzmod:2 : : : :
pum    84    inosec inostg tzopl : : : :
prez    85
tzsc    86
tzpr    87
tzoc    8a    : : : : : : : tzos
tcss    8e    : : tzck:2 : : txck:2

# Timer A (r8c-26)

tracr    100    : : tundf tedgf : tstop tcstr tstart
traioc    101    : : tipf:2 tiosel toena topcr tedgsel
tramr    102    tckcut tck:3 : tmod:3
trapre    103
tra    104

# Timer B (r8c-26)

trbcr    108    : : : : : tstop tcstr tstart
trbocr    109    : : : : : tosstf tossp tosst
trbioc    10a    : : : : inoseg inostg tocnt topl
trbmr    10b    tckcut : tck:2 twrc : tmod:2
trbpre    10c
trbsc    10d
trbpr    10e

# Timer C (r8c-1b)
tc    90    .HI
tm0    9c    .HI
tm1    9e    .HI
tcc0    9a    tc0iisb tc0int3 : tc0icp:2 tc0ssb:2 tc0sb
tcc1    9b    tc10oms:2 tc11oms:2 tc10csb tc1rs tc1if:2
tcout    ff

Re: Header file for M32C/M16C
writes
Quoted text here. Click to load it

Apart from that other compilers may also use syntax that is different to
either of those.

That is why the choice of compiler needs to be known for the header
files. If you did not know that should you be doing the project you are
on?

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.
Re: Header file for M32C/M16C
Le Mon, 19 Nov 2007 14:13:36 +0000, Chris Hills a écrit:

Quoted text here. Click to load it
Are you really understand what i'm talking about ? 'Cause i'm far from to
understand yours.

Habib

Re: Header file for M32C/M16C
Quoted text here. Click to load it

Yes I understand.

Quoted text here. Click to load it

I know. That is a problem for you

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.
Re: Header file for M32C/M16C
Le Mon, 19 Nov 2007 16:13:52 +0000, Chris Hills a écrit:

Quoted text here. Click to load it
Do you ? To say at least, your posts prove me otherwise.
Quoted text here. Click to load it
My apologies M. Hills, i do not need to understand you because there's
nothing to understand.

Habib.

Re: Header file for M32C/M16C
Quoted text here. Click to load it

There is not standard C for accessing hardware registers. You have
already been told that two compilers do it differently .  I know that
most of the compiler vendors do their header files to access hardware
differently.

I know I have to support 6 different compiler makes.


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
We've slightly trimmed the long signature. Click to see the full one.
Re: Header file for M32C/M16C
Le Mon, 19 Nov 2007 07:24:13 -0500, DJ Delorie a écrit:

Quoted text here. Click to load it

Rrriiiight ! That is exactly what i need !

Many Thanks M. Delorie.

Site Timeline