I wrote the following code to print a character on a LCD-modul (only a part of the code is shown here):
#byte BUS = 6
#separate
void put_to_lcd(char value)
{
BUS = value;
etc.
}
//example:
main()
{
...
put_to_lcd('A');
...
}
my problem: the compiler loads the argument of the function first to a normal RAM-location and then (during the function) to the PORTB.
Is there any possibility to load the argument directly to the PORTB without it loading first to an other location?
Thanks
Greetings from Switzerland
Felix
___________________________
This message was ported from CCS's old forum
Original Post ID: 215
Tomi Guest
Re: variables in function calls
Posted: Sat Sep 08, 2001 10:13 am
The problem is about parameter passing to a function. It is done either using physical stack (Neumann processor) or a software stack (Harward proc. e.g. PIC). This SW stack in a PIC looks like a "normal RAM-location".
To bypass the usage of the stack you can use a #define instead of a function:
#byte BUS = 6
#define put_to_lcd(value) BUS=value
Sample code:
.................... put_to_lcd('A');
004B: MOVLW 41
004C: MOVWF 06
To make sure that the port_B is output you can extend the statement:
#byte BUS = 6
#define put_to_lcd(value) Set_Tris_B(0);BUS=value
:=Hello (Grüezi)
:=
:=I wrote the following code to print a character on a LCD-modul (only a part of the code is shown here):
:=
:=#byte BUS = 6
:=#separate
:=void put_to_lcd(char value)
:= {
:= BUS = value;
:= etc.
:= }
:=
:=//example:
:=main()
:={
:=...
:=put_to_lcd('A');
:=...
:=}
:=
:=my problem: the compiler loads the argument of the function first to a normal RAM-location and then (during the function) to the PORTB.
:=Is there any possibility to load the argument directly to the PORTB without it loading first to an other location?
:=
:=Thanks
:=
:=Greetings from Switzerland
:=Felix
___________________________
This message was ported from CCS's old forum
Original Post ID: 216
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum