Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Port 4 for SST89E516RD2

Status
Not open for further replies.

gauravkothari23

Advanced Member level 2
Joined
Mar 21, 2015
Messages
640
Helped
5
Reputation
10
Reaction score
4
Trophy points
1,298
Activity points
6,921
Hi all,
i am working on a project where i have to use SST89E516RD2 Microcontroller. i am using Keil as a programming software. i am using 44 PIN TQFP SMD package as i contains 5 ports • Four 8-bit I/O Ports and one 4-bit Port (Port4)
when i try to build the program in keil i am getting an error (35):

error C146: 'P4': invalid base address

i have even modified the startup file and added:
Code:
sfr   P4  = 0xA5;
as per the address mentioned in the datasheet page 20.
so i need to modified something else to use this port4.
 

In general SFR values are already defined on header files specific for each device which you have to include at beginning of your program; anyway, as far as I know, the P4 register isn't bit addressable, therefore 'sfr' statement shouldn't be applicable to this register.
 

In general SFR values are already defined on header files specific for each device which you have to include at beginning of your program; anyway, as far as I know, the P4 register isn't bit addressable, therefore 'sfr' statement shouldn't be applicable to this register.

So how can i interface something on any pin of port 4.
 

Just mask it:

Code:
P4 |=    ( 1 << n )    ;     //  this turn ON  n-th pin of P4
P4 &= ~( 1 << n )     ;     //  this turn OFF n-th pin of P4
bResult &= ( 1 << n ) ;     // get value of the n-th pin of P4

Some compilers have built in operator to perform bit-oriented pinout access, even the core actually not having such a feature, but with the above fashion it turns the code portable to any toolchains, once it only make use of standard C statements. You can also put it within macro, such as :

Code:
#define SET_PORT4_PIN(x)      P4 |= ( 1 << x )
#define CLEAR_PORT4_PIN(x)      P4 &= ~( 1 << x )
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top