# serial-pic problem

Status
Not open for further replies.

#### Nigel Goodwin

##### Super Moderator
jason do you know any site that convert hex to binary (8 bit). im having trouble on my convertion.

You first need to explain what you're trying to do, but HEX to Binary is EXTREMELY easily to do, as they are very close to been the same thing (which is why HEX if used).

#### AtomSoft

##### Well-Known Member
if your on windows open your calculator and put to scientific then click HEX and enter a number then click decimal and it will convert it for you.

Understanding binary to hex and back is simple. here is how i do it:
fist you need to know binary 0-F(HEX) aka 0-15(DEC).
Binary-DEC-HEX
0000 = 0 = 0x00
0001 = 1 = 0x01
0010 = 2 = 0x02
0011 = 3 = 0x03
0100 = 4 = 0x04
0101 = 5 = 0x05
0110 = 6 = 0x06
0111 = 7 = 0x07
1000 = 8 = 0x08
1001 = 9 = 0x09
1010 = 10 = 0x0A
1011 = 11 = 0x0B
1100 = 12 = 0x0C
1101 = 13 = 0x0D
1110 = 14 = 0x0E
1111 = 15 = 0x0F

knowing that you can do larger numbers like 0x48 would be a 4 and a 8:
0100-1000.

Larger: 0x3849 =
3-8-4-9
0011-1000-0100-1001 aka 00111000001001001 simple heh.

if anything here is a online calc:HEXADECIMAL to BINARY conversion, HEX to Decimal converter, Hexdecimal convertor

##### Banned
For those of you that use Vista, there's a sidebar addon that I use called calculatorium which is a very nice scientfic command line style calculator that can be used to convert between hex/dec/octal long/short notation and has many built in functions.

#### wejos

##### Member
TY JASON.

more question thou.

Nigel heres what im trying to figure out. im a bit confused regarding the code given below (from your tutorial 7.5)

it says BCF TRISA, 0x06

but the comment says set RB6 as an output when its using TRISA. Shouldn't this suppose to be TRISB?

What am i missing here?

are we talking about RB6 here (0x06) or the value b'00000110' ?

Code:
SER_PORT	Equ	PORTA
SER_TRIS	Equ	TRISA
SER_IN		Equ	0x07
SER_OUT		Equ	0x06
LED_PORT	Equ	PORTB
LED_TRIS	Equ	TRISB

SER_INIT

BSF     STATUS, RP0           ;select bank 1
BCF     SER_TRIS, SER_OUT     ;set B6 as an output
BSF     SER_TRIS, SER_IN      ;set B7 as an input
BCF     STATUS, RP0           ;select bank 0
BSF     SER_PORT, SER_OUT     ;set SER_OUT high
RETURN

Last edited:

#### Nigel Goodwin

##### Super Moderator
TY JASON.

more question thou.

Nigel heres what im trying to figure out. im a bit confused regarding the code given below (from your tutorial 7.5)

it says BCF TRISA, 0x06

but the comment says set RB6 as an output when its using TRISA. Shouldn't this suppose to be TRISB?

What am i missing here?

are we talking about RB6 here (0x06) or the value b'00000110' ?

Ignore the comments - comments don't affect the running of a program, the program works fine.

The code will have been cut and pasted across from another tutorial, and I will have forgotten to alter the comments.

#### AtomSoft

##### Well-Known Member
Nigel for someone who makes some nice tutorials youshould know how valuable comments are.

#### wejos

##### Member
can i do this?

SER_OUT Equ b'00000110 ;insted of 0x06

#### Nigel Goodwin

##### Super Moderator
can i do this?

SER_OUT Equ b'00000110 ;insted of 0x06

Of course, number formats are completely interchangeable - but I would suggest that's a VERY bad choice to make for this particular declaration, as the binary version only confuses (each decimal, or hex, number refers to a single bit - the binary version looks like it's two bits).

#### wejos

##### Member
can i mix it up a little bit and use the 'w' register and not declare as constant

like

MOVLW 06h ;Put 00110 into W
MOVWF 85h ;Move 00110 onto TRISA

0x06 and 06h is the same right?

ty guys you guys are good teacher ive learned a lot from you guys.

Last edited:

#### wejos

##### Member
i have discovered the problem.

16f84 does not have RA6 and RA7 whilst 16F628 have them.

16F628:

16f84:

thats why i was confused why theres 0x06 in TRISA when theres only 5 bits in my 16f84's port a

Last edited:

#### AtomSoft

##### Well-Known Member
i even forgot you was using the 16F84 heh. glad you figured tht out

Status
Not open for further replies.

Replies
2
Views
2K
Replies
20
Views
2K
Replies
1
Views
1K
Replies
13
Views
1K
Replies
12
Views
3K