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.

Hex to Convertor for PIC controller

Status
Not open for further replies.

venkates2218

Full Member level 6
Full Member level 6
Joined
Sep 30, 2016
Messages
354
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
4,306
Hai,
I need to interface multiplexer with PIC18F452 controller with multiplexer.
In this,the data which provide to multiplexer will be like hex number like this
char enoder_data[] = {0xB8, 0xB7, 0xBA, 0xBB, 0xBC};

Have to convert hex value to binary values.
So I tried like this char enoder_data[] = {"B8", "B7", "BA", "BB", "BC"}; to convert into binary value but warning: excess elements in char array initializer error is generated.

How to convert the hex number to binary number.?
 

???
Hex and binary are the same thing. Hex is just an easier way of expressing lots of ones and zeroes.
You can write the identical values in binary if you like by substituting the '0x' with '0b' and following it with the 8 bits but it makes absolutely no difference to the compiler whatsoever.
Code:
char enoder_data[] = {"B8", "B7", "BA", "BB", "BC"};
almost certainly would give that error, you declare an array of char sized values but do not give it any size then try to store five string values in it. Try putting the array size inside the [ ] so the compiler knows how much memory to reserve for storage and going back to the original 0x values.

Brian.
 

Hi,

Example:
All below is the same value: (8 bits = 1 byte)
* 65 (decimal)
* 0x41 (hex)
* 0b01000001 (binary)
* "A" (ASCII)
* 0101 (octal)

It's urgent to learn representation of bytes, numbers, values, characters...

Klaus
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top