bitsurfer
Member level 3
Hello,
I am absolute beginner in microcontrollers and uC programming.
With some experience in PC C programming I started with first program in keil C.
So I have few questions for experienced programmers.
1) In my uVision3 project I have included file "AT89X51.H" in which bit 0 of port 2 is defined as:
Later in program I want to simplify this bit by giving him understandable name, like:
... but I get error "BLINK.C(12): error C146: 'P2_0': invalid base address"
However, later I find that I can declare "relay" as such: "sbit relay = P2^0;" or "sbit relay = 0xA0;" but anyway I would like to know why I can't assign "P2_0" to "relay" when both are of same type (sbit).
2) My first project is a simple counter with few delays which shift led's, turn on/off relay and print counted number to lcd.
Somewhere in my code I have to make a string (unsigned char[]) from my (counted ) number so I include <stdio.h> at top of program and use
... like I would do in C programming at PC.
But while all program (hex) is long about 1,5 kb this single line takes additional 3 kb of program!
Using <stdio.h> seems to me very comfortable for use but price (in bytes) seem's very high.
Is this normal?
And if is:
How to convert counted number to char array to be suitable to show on display without too much spended bytes?
I am absolute beginner in microcontrollers and uC programming.
With some experience in PC C programming I started with first program in keil C.
So I have few questions for experienced programmers.
1) In my uVision3 project I have included file "AT89X51.H" in which bit 0 of port 2 is defined as:
Code:
sbit P2_0 = 0xA0;
Later in program I want to simplify this bit by giving him understandable name, like:
Code:
sbit relay = P2_0;
However, later I find that I can declare "relay" as such: "sbit relay = P2^0;" or "sbit relay = 0xA0;" but anyway I would like to know why I can't assign "P2_0" to "relay" when both are of same type (sbit).
2) My first project is a simple counter with few delays which shift led's, turn on/off relay and print counted number to lcd.
Somewhere in my code I have to make a string (unsigned char[]) from my (counted ) number so I include <stdio.h> at top of program and use
Code:
sprintf(buf1, "%d", counted);
But while all program (hex) is long about 1,5 kb this single line takes additional 3 kb of program!
Using <stdio.h> seems to me very comfortable for use but price (in bytes) seem's very high.
Is this normal?
And if is:
How to convert counted number to char array to be suitable to show on display without too much spended bytes?