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.

But1 Equ 0x00

Status
Not open for further replies.
Dear kubeek,
I thought ask one more question please help

LCD_RS Equ 0x04

How can we decided LCD_RS reference to which port of which pin?

Please advice
Thanks in advance
 
Dear Nigel Thanks for the reply,

LCD_PORT Equ PORTA
LCD_TRIS Equ TRISA
LCD_RS Equ 0x04 ;LCD handshake lines
LCD_RW Equ 0x06
LCD_E Equ 0x07


Is above has PORT specified separately

#DEFINE LCD_RS PORTA,0 ; This is the method I know. what should be the other methods


Please advice
Thanks in advance
 
Last edited:
Dear Nigel Thanks for the reply,

LCD_PORT Equ PORTA
LCD_TRIS Equ TRISA
LCD_RS Equ 0x04 ;LCD handshake lines
LCD_RW Equ 0x06
LCD_E Equ 0x07


Is above has PORT specified separately

#DEFINE LCD_RS PORTA,0 ; This is the method I know. what should be the other methods

I'm really struggling to see your problem? - both define and equ are basically simple text substitution instructions.

The reason I did it the way I did, setting the port and the pin independently is so you can simply change just one or the other with just ONE text change.

The define example you give above would require every pin declaration changing if you moved the port, my method means you only change one.

I considered this important in my tutorials, as different ones use the LCD on different ports, this makes it easy to move the routines over.
 
Dear Nigel Thanks for the reply

Please accept my apologize for any inconvenience cause

Still I don't understand or the way I asked problem may be wrong.

I ask like this

I want to configure RS pin of LDC connect to PORTA,4,

LCD_PORT EQU PORTA ; Understood


LCD_RS EQU PORTA,4 ; pin 4 of PORTA as LCD_RS

bsf LCD_PORT , LCD_RS ; YES Understood

LCD_RS equ 0x04; my question is how we know ( 0x04 ) is pin 4 of PORTA

Please help or try to understand my Quentin at lease

Thanks in advance
 
I ask like this

I want to configure RS pin of LDC connect to PORTA,4,

LCD_PORT EQU PORTA ; Understood


LCD_RS EQU PORTA,4 ; pin 4 of PORTA as LCD_RS

bsf LCD_PORT , LCD_RS ; YES Understood


If you define " LCD_RS EQU PORTA,4"
Then you just have to do "BSF LCD_RS" not "BSF LCD_PORT, LCD_RS"


LCD_RS equ 0x04; my question is how we know ( 0x04 ) is pin 4 of PORTA


If you define " LCD_RS equ 0x04"
Then you need to do "BSF LCD_PORT, LCD_RS"


Please help or try to understand my Quentin at lease

Thanks in advance

I hope you get it.

Allen
 
Last edited:
Dear Allen thanks for your reply

I think i got some think

LCD_RS equ 0x04 mean LCD_RS = 4 ; am I correct?


Then we can use LCD_RS every where instead of 4, Am I correct?

Ex.

bsf PORTA,LCD_RS ; set PORTA bit4

bcf PORTB,LCD_RS ; clear PORTB pin4

Please re correct me I am wrong

Please help
Thanks in advance
 
Yes, but more specifically whenever the compiler finds LCD_RS in the source code it literally replaces it with 0x04. After that it does second pass and compiles the source code to binary.
 
If you define " LCD_RS EQU PORTA,4"
Then you just have to do "BSF LCD_RS" not "BSF LCD_PORT, LCD_RS"


If you define " LCD_RS equ 0x04"
Then you need to do "BSF LCD_PORT, LCD_RS"

Dear Allen you change my life using above four sentence

Thanks again and again

Thanks Nigel for your fullest suport
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top