Re: I/O commands using ICC12 and D-Bug12

Started by gottipatirk October 11, 2005
Hi

How do you specify the pointer address for the subroutines that are
developed in C for I/O operations (like getchar, putchar, prinntf) for
a MC9S12DP256 microcontroller and developing C programs using ICC12
software and D-Bug12 debugger

Thanks in Advance
Rama



Rama,

I'm afraid I don't understand your question. The pointer that is an
argument to those instructions is a pointer to a standard C string, so
you would use it like this:

int c;

c = getchar();
putchar(c);

printf(" (ASCII code %d)\n", c);

How these functions map to the SCI ports is specific to your C compiler's
run-time library. Check the documentation. With some compilers, you
will need to modify the putchar() and getchar() functions in order to
switch SCI ports. (Just copy them to your code, then change the register
names appropriately.)

If you were talking about how to access the D-Bug12 I/O functions,
that's a different problem. I'd be inclined to use the C compiler's
library functions instead, because that is simpler.

Stephen

--
Stephen Trier
Technical Development Lab
Cleveland FES Center
sct@sct@...



Hi Steve
Thanks for the instant reply and the follow-up on the mail i sent
you.
Yes i do know there are two different I/O functions, one from C
library and one provided by D-Bug12. I am just using the c library
finctions by including the stdio.h library.

Problem is it stays in an infinite loop.

Here is the code

#include <hcs12dp256.h>
#include <stdio.h>

int j;

main()
{
j = getchar();
putchar(j);

while(1)
{
}
return(0);
}

Here is the generated list file

WARNING: EXTCODE CODE AREA DO NOT CONTAIN RELOCATED ADDRESSES.
THIS WILL BE REMEDIED IN A LATER RELEASE.
.module test1.c
.area text
122A _main::
122A ; #include <hcs12dp256.h>
122A ; #include <stdio.h>
122A ;
122A ; int j;
122A ;
122A ; main()
122A ; {
122A ; j = getchar();
122A 16126B jsr _getchar
122D 7C1000 std _j
1230 ; putchar(j);
1230 FC1000 ldd _j
1233 87 clra
1234 161243 jsr _putchar
1237 ; asm("SWI");
1237 3F SWI
1238
1238 L4:
1238 L5:
1238 ; while(1)
1238 20FE bra L4
123A X0:
123A ; {
123A ; }
123A ; return(0);
123A CC0000 ldd #0
123D L3:
123D .dbline 0 ; func end
123D 3D rts
.area bss
1000 _j::
1000 .blkb 2 Here is the map file generated

Area Addr Size Decimal Bytes
(Attributes)
-------------------------------- ---- ---- ------- ----- ------
------
text 1200 0074 = 116. bytes
(rel,con,rom)

Addr Global Symbol
----- --------------------------------
1200 __start
1228 _exit
122A _main
122A __text_start
123D __HC12Setup
1242 _putchar
126A _getchar
1274 __text_end

Area Addr Size Decimal Bytes
(Attributes)
-------------------------------- ---- ---- ------- ----- ------
------
bss 1000 0004 = 4. bytes
(rel,con,rom)

Addr Global Symbol
----- --------------------------------
1000 __bss_start
1000 _j
1002 __textmode
1004 __bss_end

Files Linked [ module(s) ]

C:\icc\lib\crt12.o [ crt12.s ]
test1.o [ test1.c ]
<library> [ setup.s, putchar.s, getchar.s, textmode.s ]

User Global Definitions

init_sp = 0x3c00

User Base Address Definitions

text = 0x1200
data = 0x1000 Thanks in advance to the members of the group for any suggestions

Rama



Hi Rama, it is as Stephen said, you need to write your own putchar. The
default one in the library only works for the older devices. The S12DG256
uses different IO register locations and hence the function loops forever.

We plan to release an update where the linker will be able to at least
inform you that the function is device specific, and you need to write it
yourself. We just implemented it for the AVR compiler, and the output looks
like this:

!ERROR Function 'putchar' not defined. This is a function that references
the device's IO register locations and must be compiled specifically
for the target device. You may find examples of this function for
different devices under the <install root>\examples.12 directory.

In your case, add putchar.c or putchar_dp256.c (or a copy) in the
<install>\examples.12 directory to your project file list, then change the
IO header file to reference the DP256. Build and you should be good to go.

At 12:43 PM 10/11/2005, gottipatirk wrote:

>Hi Steve
>Thanks for the instant reply and the follow-up on the mail i sent
>you.
>Yes i do know there are two different I/O functions, one from C
>library and one provided by D-Bug12. I am just using the c library
>finctions by including the stdio.h library.
>
>Problem is it stays in an infinite loop.
>
>Here is the code

// richard (This email is for mailing lists. To reach me directly, please
use richard at imagecraft.com)


Hi richard

Thanks for the reply.
So when i write my own putchar or getchar fiunction such as putchar.c
and getchar.c, i need to set the SCI0 and either read the data or
write the data to the transmit or recive buffer. Is this the way we
implement the function or its totally something else

Please let me know

Rama --- In 68HC12@68HC..., Richard <richard-lists@i...> wrote:
>
> Hi Rama, it is as Stephen said, you need to write your own putchar. The
> default one in the library only works for the older devices. The
S12DG256
> uses different IO register locations and hence the function loops
forever.
>




Right! The function printf just calls putchar, so as long as you implement
a putchar() suitable for your device, printf etc. will work fine. For more
info, check the Help file on "Standard IO functions."

At 01:09 PM 10/11/2005, gottipatirk wrote:

>Hi richard
>
>Thanks for the reply.
>So when i write my own putchar or getchar fiunction such as putchar.c
>and getchar.c, i need to set the SCI0 and either read the data or
>write the data to the transmit or recive buffer. Is this the way we
>implement the function or its totally something else
>
>Please let me know
>
>Rama >--- In 68HC12@68HC..., Richard <richard-lists@i...> wrote:
> >
> > Hi Rama, it is as Stephen said, you need to write your own putchar. The
> > default one in the library only works for the older devices. The
>S12DG256
> > uses different IO register locations and hence the function loops
>forever.
> >Yahoo! Groups Links >
>

// richard (This email is for mailing lists. To reach me directly, please
use richard at imagecraft.com)