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.

[General] Writing to MCU data port

Status
Not open for further replies.

hithesh123

Full Member level 6
Full Member level 6
Joined
Nov 21, 2009
Messages
324
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
lax
Visit site
Activity points
3,548
I have a char array of parity bits, to be written to MCU port out.
The MCU port is called data1. I am trying to write array[2] to data1

data1=array[2];

array[2]='0' , But when I step thru the code, data1 becomes 1 after the above assignment.
I have both 0s and 1s in the array. But no matter what the array index is, data1 always becomes 1 after I execute
data1=array[2];
Can 'char' data type be assigned to port pins?
 


Code C - [expand]
1
2
3
4
5
6
7
8
9
mask = 0x01
for(i = 0; i < 8; i++){
    if(array[2] & mask)
        data1 = 1;
    else
        data1 = 0;
    
    mask = mask << 1;
}




Code C - [expand]
1
2
3
4
5
6
mask = 0x01
for(i = 0; i < 8; i++){
    (array[2] & mask)? data1 = 1 : data1 = 0;
    
    mask = mask << 1;
}

 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top