platformio / platform-intel_mcs51

Intel MCS-51 (8051): development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/intel_mcs51
Apache License 2.0
56 stars 45 forks source link

Add stc example #15

Closed znhocn closed 5 years ago

zerog2k commented 6 years ago

@znhocn regarding the stc specific headers, I wonder if using a different declaration format would make it easier for editors like vscode to manage c intellisense better. I think this worked better for me https://github.com/zerog2k/stc_diyclock/blob/master/src/stc15.h

e.g. using

__sfr __at 0x12 REG_FOO;

instead of

SFR(REG_FOO, 0x12);

Not sure which is the preferred way, but I think for some reason vscode doesnt like these SFR/SBIT/etc macro style for discovering declarations of sfrs, etc.

zerog2k commented 6 years ago

well disregard last comment, I am not sure that vscode understands sfr/sbit syntax either...

znhocn commented 6 years ago

@zerog2k I think VSCode understands the __sfr/__sbit syntax. I tried it and there is no error.

There are two syntaxes __sfr/__sbit and SFR()/SBIT() in the header file provided by SDCC.

C:\Users\<name>\.platformio\packages\toolchain-sdcc\include\mcs51\

I am not sure which syntax is better.

Why do I use SFR()/SBIT() syntax ? Because it's easier to modify from the STC original header.

STC Original Header:

sfr ACC         =   0xE0;
sfr B           =   0xF0;
sfr PSW         =   0xD0;
sbit CY         =   PSW^7;
sbit AC         =   PSW^6;
sbit F0         =   PSW^5;

sfr P4          =   0xC0;
sbit P40        =   P4^0;
sbit P41        =   P4^1;
sbit P42        =   P4^2;
sbit P43        =   P4^3;

The STC original header is used in the keil compiler and cannot be used in SDCC.

ivankravets commented 5 years ago

Thanks!