Code size
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
> char ch = ((char)"W");
>
Not quite sure what you are trying to do here.
char ch = 'W'; // probably what you wanted
Not sure why you are initializing that variable anyway, you do realize
that burns up extra code space.
in coridium.h
#define ULSR_TEMT (1 << 6) // Transmitter Empty
rather than the if, it should be
while ((UART0_LSR & ULSR_TEMT) == 0);
UART0_THR = (char)ch;
>
Not quite sure what you are trying to do here.
char ch = 'W'; // probably what you wanted
Not sure why you are initializing that variable anyway, you do realize
that burns up extra code space.
in coridium.h
#define ULSR_TEMT (1 << 6) // Transmitter Empty
rather than the if, it should be
while ((UART0_LSR & ULSR_TEMT) == 0);
UART0_THR = (char)ch;
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
This is the first line in my program after init_coridium. It should
execute every time that I reset from TlcTerm. I get nothing in the
TlcTerm window. I must be missing something in the Uart0 setup.
UART0_THR = (char)'W';
execute every time that I reset from TlcTerm. I get nothing in the
TlcTerm window. I must be missing something in the Uart0 setup.
UART0_THR = (char)'W';
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
I reloaded cor_init.c from C Sources into libarm7, and carefully
removed the UART1 setup code, just to get enough space to run my
program on the ARMmite board. I still get no results on TlcTerm.
Just a side note. I have reduced my code to 32.26K, but if It set the
Flash Memory length to < 0x00008300 the compiler produces a link
error. Is there some buffer required?
removed the UART1 setup code, just to get enough space to run my
program on the ARMmite board. I still get no results on TlcTerm.
Just a side note. I have reduced my code to 32.26K, but if It set the
Flash Memory length to < 0x00008300 the compiler produces a link
error. Is there some buffer required?
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
I copied my program to another file, and then commented out all the
variables and code. I wrote a couple of lines to toggle the LED, and to
write a Character to the Terminal:
uart0Putch((char)'W');
This took about 7K of space. I set the ROM Length back to 8000 hex.
This program runs and writes 'W's to the Terminal.
Then I made a Char array named string and used:
uart0Puts(string);
This program writes the string to the Terminal.
My conclusion is that I must leave enough space fit the code and data
into 32,768. Having the code under 32K doesn't work, if the data causes
it to overflow.
> Just a side note. I have reduced my code to 32.26K, but if It set the
> Flash Memory length to < 0x00008300 the compiler produces a link
> error. Is there some buffer required?
>
variables and code. I wrote a couple of lines to toggle the LED, and to
write a Character to the Terminal:
uart0Putch((char)'W');
This took about 7K of space. I set the ROM Length back to 8000 hex.
This program runs and writes 'W's to the Terminal.
Then I made a Char array named string and used:
uart0Puts(string);
This program writes the string to the Terminal.
My conclusion is that I must leave enough space fit the code and data
into 32,768. Having the code under 32K doesn't work, if the data causes
it to overflow.
> Just a side note. I have reduced my code to 32.26K, but if It set the
> Flash Memory length to < 0x00008300 the compiler produces a link
> error. Is there some buffer required?
>
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
That's it. I need to keep my program < 31300K since I have 1440 bytes
of data.
I commented out a couple of procedures in my program and downloaded
it. The program space is 31.25K and the data space is 1.44K. I am now
able to send strings to the terminal.
Now I have to find a way to further reduce the code.
of data.
I commented out a couple of procedures in my program and downloaded
it. The program space is 31.25K and the data space is 1.44K. I am now
able to send strings to the terminal.
Now I have to find a way to further reduce the code.
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
It sounds as if you are initializing 1440 bytes of data to something
other than 0
Is that necessary?
other than 0
Is that necessary?
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
I have several Constant Tables, and many Constant Floating Point and
Integer values. These must remain in Flash Memory, although at some
point in time, their values could be changed by reflashing the memory
locations. At this stage, I have no plans to reflash the values.
I'll try to do a rough count of the bytes to determine if it is 1440.
It may be possible to reduce the size of some tables, but I don't
expect to get 1K.
Integer values. These must remain in Flash Memory, although at some
point in time, their values could be changed by reflashing the memory
locations. At this stage, I have no plans to reflash the values.
I'll try to do a rough count of the bytes to determine if it is 1440.
It may be possible to reduce the size of some tables, but I don't
expect to get 1K.
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
I have counted 1520 bytes of constant data. I don't see any further
opportunity to reduce these constants.
I don't think that I need the following code in the HWPWM function:
{
switch (cnt) {
case 8:
if((PCB_PINSEL1 & 0x000000c0) ==
0x00000080 ) //IO(11)
PCB_PINSEL1 &= ~0x000000c0;
break;
case 7:
if((PCB_PINSEL0 & 0x0c000000) ==
0x08000000 ) //IO(10)
PCB_PINSEL0 &= ~0x0c000000;
break;
case 6:
if((PCB_PINSEL0 & 0x0000c000) ==
0x00008000 ) //IO(9)
PCB_PINSEL0 &= ~0x0000c000;
break;
case 5:
if((PCB_PINSEL1 & 0x00000300) ==
0x00000200 ) //IO(4)
PCB_PINSEL1 &= ~0x00000300;
break;
case 4:
if((PCB_PINSEL1 & 0x00000c00) ==
0x00000800 ) //IO(3)
PCB_PINSEL1 &= ~0x00000c00;
break;
case 3:
if((PCB_PINSEL1 & 0x30000000) ==
0x20000000 ) //IO(2)
PCB_PINSEL1 &= ~0x30000000;
break;
case 2:
if((PCB_PINSEL0 & 0x00030000) ==
0x00020000 ) //IO(1)
PCB_PINSEL0 &= ~0x00030000;
break;
case 1:
if((PCB_PINSEL0 & 0x000c0000) ==
0x00080000 ) //IO(0)
PCB_PINSEL0 &= ~0x000c0000;
break;
}
}
Eliminating that code saves about 300 bytes.
Why do I need that code?
opportunity to reduce these constants.
I don't think that I need the following code in the HWPWM function:
{
switch (cnt) {
case 8:
if((PCB_PINSEL1 & 0x000000c0) ==
0x00000080 ) //IO(11)
PCB_PINSEL1 &= ~0x000000c0;
break;
case 7:
if((PCB_PINSEL0 & 0x0c000000) ==
0x08000000 ) //IO(10)
PCB_PINSEL0 &= ~0x0c000000;
break;
case 6:
if((PCB_PINSEL0 & 0x0000c000) ==
0x00008000 ) //IO(9)
PCB_PINSEL0 &= ~0x0000c000;
break;
case 5:
if((PCB_PINSEL1 & 0x00000300) ==
0x00000200 ) //IO(4)
PCB_PINSEL1 &= ~0x00000300;
break;
case 4:
if((PCB_PINSEL1 & 0x00000c00) ==
0x00000800 ) //IO(3)
PCB_PINSEL1 &= ~0x00000c00;
break;
case 3:
if((PCB_PINSEL1 & 0x30000000) ==
0x20000000 ) //IO(2)
PCB_PINSEL1 &= ~0x30000000;
break;
case 2:
if((PCB_PINSEL0 & 0x00030000) ==
0x00020000 ) //IO(1)
PCB_PINSEL0 &= ~0x00030000;
break;
case 1:
if((PCB_PINSEL0 & 0x000c0000) ==
0x00080000 ) //IO(0)
PCB_PINSEL0 &= ~0x000c0000;
break;
}
}
Eliminating that code saves about 300 bytes.
Why do I need that code?
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
I rewrote the HWPWM Function, and replaced the first 'switch (cnt)'
procedure with a nested if - else. That along with elimination of the
second 'switch (cnt)' procedure has gotten my code down to 31.86K. I
need to remove another 500 bytes from the program.
procedure with a nested if - else. That along with elimination of the
second 'switch (cnt)' procedure has gotten my code down to 31.86K. I
need to remove another 500 bytes from the program.
-
YahooArchive
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Code size
I have been working hard on my program, and I now need to eliminate
another 32 bytes to get the program to download. It has been diffcult
and those 32 bytes are going to be like dental extractions.
I still have a functional uart0putch function, so I will be able do
some monitoring the operations, if I can get enough space to call the
function.
another 32 bytes to get the program to download. It has been diffcult
and those 32 bytes are going to be like dental extractions.
I still have a functional uart0putch function, so I will be able do
some monitoring the operations, if I can get enough space to call the
function.