Re: linking imagecraft compiler with assember file
From: fabrizio (fabrizio_dagnolo_at_hotmail.com)
Date: 12/28/03
- Next message: Ralph Malph: "Re: Low cost PCB layout software"
- Previous message: Colin MacDougall: "Re: Newbie asking 4 Hints on a board to practice on"
- In reply to: Rich Webb: "Re: linking imagecraft compiler with assember file"
- Next in thread: Rich Webb: "Re: linking imagecraft compiler with assember file"
- Reply: Rich Webb: "Re: linking imagecraft compiler with assember file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Dec 2003 03:10:19 -0800
Rich Webb <bbew.ar@mapson.nozirev.ten> wrote in message news:<2vpruvkg8htlbrg93dpn8oo2ngqhkd1p88@4ax.com>...
> On 27 Dec 2003 11:49:04 -0800, fabrizio_dagnolo@hotmail.com (fabrizio)
> wrote:
>
> >Hi,
> >
> >I am using the IMAGECRAFT compiler to program the ATMEGA16 device.
> >I'm trying to write a PC program, using Delphi, to make a monitor that
> >will be
> >able to manipulate SRAM memory on the ATMEGA16 device. The PC is
> >connected
> >via RS232 to the Device.
> >
> >For example:
> >Command entered on the PC : D 0060 10
> >Meaning: Display 10H Bytes starting from SRAM address 0060H
> >
> >The PC part of the Job is working 'fine'.
> >The IMAGECRAFT ANSI C program running on the device is receiving the
> >command and should start with the Display task.
> >
> >Here i am stuck.
> >
> >I can't find an ANSI C instruction that reads out SRAM locations.
>
> It's inherent in the language, although necessarily non-portable.
>
> Try not a variation on:
>
> void DisplayByte(unsigned char); // magic user function
>
> ...
> unsigned char *pByte;
> unsigned char i;
> ...
>
> for (i = 0, pByte = (unsigned char *)0x0060; i < 0x10; ++i) {
> DisplayByte(*(pByte + i));
> }
>
> Non-portable, of course, but what's being done is non-portable as well.
>
> >I think the way to go is, from the ANSI C program calling an Assembler
> >procedure, with Address 0060 has a parameter, let the assembler
> >procedure load the byte located at address 0060, and pass it back the
> >the ANSI C Program who will send the SRAM-data to the PC application.
> >
> >Can someone help me with indications on how to interface, and link,
> >the
> >IMAGRCRAFT Compiler with Assembler files?
>
> It's not really needed in this application but see the help files under
> "Assembly Interface and Calling Conventions". Just add the .s file to
> the project.
Thanks for reply,
I tested your suggestion and it work's. You are good.
Here is what i made out of it:
What you have to know upfront, is that in the ATMEGA16 device i
declared and
Cmd_Buffer array where the Command coming from the PC is stored has
consecutive bytes. Cmd_Buffer_Poi points to the individual bytes in
this
array.
Example
-------
Command entered on PC : D 09A0 5
Meaning: Display 5 bytes starting from SRAM location '09A0'
Cmd_Buffer in Device looks like: 00,09,A0,05
Meaning: 00 Internal Code identifying Display Action
09 High byte of Address
A0 Low byte of Address
05 Number of Bytes to Display
Procedure Handle_Display_SRAM is enterred with Cmd_Buffer_Poi poiting
to the
first '00', the Internal Code identifying Display Action
void Handle_Display_Sram(void)
/* Handle the Display of SRAM data */
{
unsigned int Address;
unsigned char Length, i;
unsigned char *Pbyte;
Cmd_Buffer_Poi++; /* Point to high byte Address */
/* Find address out of Cmd_Buffer */
Address = *Cmd_Buffer_Poi << 8; //Address = 0x0900
Cmd_Buffer_Poi++; /* Point to low byte Address */
Address = Address + *Cmd_Buffer_Poi; //Address = 0x09A0
/* Find length of bytes to display out of Cmd_Buffer */
Cmd_Buffer_Poi++; /* Points to Length indicator
Length = *Cmd_Buffer_Poi; // Length = 0x05
/* Enter Loop to display all SRAM bytes */
for (i=0, Pbyte = (unsigned char *)Address; i < Length; i++)
{
Character_To_Tx = *(Pbyte+i);
}
} /* void Handle_Display(void); */
Global Variable Character_To_Tx will get the Value of the Data bytes
located at
Address 09A0 -> 09A4 PERFECT !!!!
The Key statement is --> Pbyte = (unsigned char *)Address <--
This statement i don't understand completely.
Pbyte is a pointer to an unsigned Char
Address is an unsigned Integer
What is "(unsigned char *)" doing to the Unsigned Integer ???
Regards,
Fabrizio,
- Next message: Ralph Malph: "Re: Low cost PCB layout software"
- Previous message: Colin MacDougall: "Re: Newbie asking 4 Hints on a board to practice on"
- In reply to: Rich Webb: "Re: linking imagecraft compiler with assember file"
- Next in thread: Rich Webb: "Re: linking imagecraft compiler with assember file"
- Reply: Rich Webb: "Re: linking imagecraft compiler with assember file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|