Niño Canizales

how to make a sum of binary numbers, taking half of a port as bits?   

Discussion created by Niño Canizales on May 13, 2018
(before I start, I apologize for my English)


Im ussing lpcXpresso1769

I am a student, and they commissioned me a task that consists in performing a binary adder,
add, for example 1111 + 1110, in which the values of each byte are the state values of a
dip switch, Im using the port 0. The only thing What I have managed to do is read the value
of the port and assign it to a led bar to turn on and off the led bar. Iwant to know how, from that port that has 8 values, get the first 4 and store them in one
vvariable, and read the last 4 values and store them in another variable, and perform the binary
summation by programming with code. My teacher is bad, maybe my concept of binary addition is wrong and done differently in a
microcontroller and maybe there are bookstores that do that, but as I have little knowledge
that's why I ask for your help.



The next code only read port0 and assing his value to other port

void CONFIG_GPIO (void);//prototipo de la funcion
void Int_Out (void);

char Inputs;

int main(void)

CONFIG_GPIO ();//llamada a la funcion



void CONFIG_GPIO (void)//funcion
GPIO_SetDir(2,0x000000FF, 1);
GPIO_SetDir(0,0x000000FF, 0);
void Int_Out(void)
Inputs= GPIO_ReadValue(0);


Thanks in advance