Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

serial-pic problem

Status
Not open for further replies.
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

and here is more info on how to do it:
Converting binary and hexadecimal values
 
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.
 
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:
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.
 
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).
 
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:
i have discovered the problem.

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

16F628:
**broken link removed**

16f84:

**broken link removed**




thats why i was confused why theres 0x06 in TRISA when theres only 5 bits in my 16f84's port a
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top