gnupic: Here's a simple working GPAL example


Previous by date: 24 Oct 2004 15:08:02 +0100 Help! How do i 'include' a module in GPAL?, David McNab
Next by date: 24 Oct 2004 15:08:02 +0100 Re: gpsim gui screen shot, Easy B
Previous in thread:
Next in thread: 24 Oct 2004 15:08:02 +0100 Re: Here's a simple working GPAL example, Craig Franklin

Subject: Here's a simple working GPAL example
From: David McNab ####@####.####
Date: 24 Oct 2004 15:08:02 +0100
Message-Id: <417BB73A.4000303@rebirthing.co.nz>

David McNab wrote:
 > Hi,
 >
 > How do I import another module into a GPAL module?
<snip>

After a bit more playing around, I realised that:
1) the .pub files for whatever modules are being imported have to be 
listed on the gpal command line
2) the 'with "modulename" has to appear in the importing module.

So my first successful 'hello, world' GPAL prog (for the benefit of others):

1. The code - helloleds.pal

   module helloleds is

        with p16f873a;

   pragma processor = "16f873a";
   pragma udata_section = "BANK0";

   procedure main is

     begin
        p16f873a.TRISB = 0x00;
        p16f873a.PORTB = 0xa5;
        asm
          sleep
        end asm;
     end procedure;

   end module;

2. Compiling the module:

   $ gpal -c helloleds.pal p16f873a.pub

3. Linking the module:

   $ gplink -s default.lkr -a inhx8m -c -o helloleds.hex helloleds.o

   (For the 'default.lkr' link script, I'm using the standard 16f873a.lkr
   gputils link script, with the extra line:

    SECTION    NAME=BANK0    RAM=gpr0

4. Download the program, and it works

(phew!)

-- 
Cheers
David

Previous by date: 24 Oct 2004 15:08:02 +0100 Help! How do i 'include' a module in GPAL?, David McNab
Next by date: 24 Oct 2004 15:08:02 +0100 Re: gpsim gui screen shot, Easy B
Previous in thread:
Next in thread: 24 Oct 2004 15:08:02 +0100 Re: Here's a simple working GPAL example, Craig Franklin


Powered by ezmlm-browse 0.20.