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.

[SOLVED] wait time to do instruction

Status
Not open for further replies.

vishy71

Full Member level 2
Joined
Dec 16, 2010
Messages
126
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Iran
Activity points
2,295
hi

who can say what time I must wait to lcd run the instruction please?
...and send other data?


and I must make my shape and write it in CGRAM to show on lcd?
how can I?i mean what instructions I must send?


thanks

---------- Post added at 10:41 ---------- Previous post was at 10:41 ----------

oh sorry I forget! I use 8 bit LCD!
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,149
Reputation
4,304
Reaction score
2,089
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,086
if you read the data sheet it clearly gives the time for every command .... its usually varies between 100 to 200msecs,,but its specific to specific manufacturers... it makes no difference to lcd if you use it as 8 bit or 4 bit mode.... download lcd12.pdf you find your answer or get datasheet from manufacturer of lcd for excat timing issues
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating

vishy71

Full Member level 2
Joined
Dec 16, 2010
Messages
126
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Iran
Activity points
2,295
thanks!

I how time I must wait but I expriment little times and it answer!I mean instead (for example) 100ms wait!I wait 20ms!
or instead 5ms I wait 500us!
may it give me a problem!

---------- Post added at 13:47 ---------- Previous post was at 13:41 ----------

I wanna show TMR0 value on LCD! 8 bit LCD!
but I don't know how to do it!
this is my code!

movf TMR0,0
call LCD_CHR ;show character on LCD

I wanna show numberial value!can you help me please?
 

DineshSL

Advanced Member level 1
Joined
May 10, 2010
Messages
403
Helped
121
Reputation
242
Reaction score
116
Trophy points
1,343
Location
Sri Lanka
Activity points
3,551
Hi,

You should only wait in LCD-Initializing step. (using delay routines)

After that, when you write something on LCD, you can check Busy-Flag of LCD. Before issuing LCD-instruction you keep checking it until it's Not-busy.

This will ensure correct operation. Your experiment is good; but we can't expect it works that way always.
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating

g_shyam1682

Full Member level 4
Joined
Jan 11, 2010
Messages
206
Helped
53
Reputation
106
Reaction score
43
Trophy points
1,308
Location
Udaipur-Rajshan-India
Activity points
2,551
Hi friend

I wanna show TMR0 value on LCD! 8 bit LCD!
but I don't know how to do it!

For timer value display on LCD,
First of all, Initialize LCD

My Code for initialize LCD is below
void init_lcd(void)
{
RS = 0;
lcd_data = 0x38;
EN = 1;
EN = 0;
wait_lcd();

RS = 0;
lcd_data = 0x0C;
EN = 1;
EN = 0;
wait_lcd();

RS = 0;
lcd_data = 0x06;
EN = 1;
EN = 0;
wait_lcd();
}

Then Clear LCD Memory
My Code for that is below

void clear_lcd(void)
{
RS = 0;
lcd_data = 0x01;
EN = 1;
EN = 0;
wait_lcd();
}

Then send Address for where you display character on LCD(Keep RS = 0)
Then send ASCII Value for your Character, which is you want display on LCD( Keep RS = 1)

Here,
RS and EN are two pin of LCD which must be connected with Micro controller.

Hope This is help you
Shyam
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating

vishy71

Full Member level 2
Joined
Dec 16, 2010
Messages
126
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Iran
Activity points
2,295
thanks! but TMR0 value is hex! I wanna convert it to ask or decimal!
what instruction must I use?
 

DineshSL

Advanced Member level 1
Joined
May 10, 2010
Messages
403
Helped
121
Reputation
242
Reaction score
116
Trophy points
1,343
Location
Sri Lanka
Activity points
3,551
Hi,

Yes, First you need to convert TIMR0 value to Decimal. Since you timer is 8bit there will be 3 digits which may store at 3 separate registers. Then you can write them on LCD.

To convert binary to Decimal, using assembly is bit difficult. You can write the code with C compiler and convert it to assembly.
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,149
Reputation
4,304
Reaction score
2,089
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,086
YOU CANNOT SHOW TIMER values in lcd as timer increments in microseconds........

DONT KNOW WHAT OTHERS ARE EXPLAINING OR I HAVE MISUNDERSTOOD YOUR REQUIREMENT......
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating

vishy71

Full Member level 2
Joined
Dec 16, 2010
Messages
126
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Iran
Activity points
2,295
Hi

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
I wanna show timer on LCD!but it's source is RA4!
you can't understand my mean?
well!!!!sorry my english is not good!

times is not increasment as I wanna show it on LCD!this is simple! any way! I wanna show 65 on LCD not a! how can I do it!
 

DineshSL

Advanced Member level 1
Joined
May 10, 2010
Messages
403
Helped
121
Reputation
242
Reaction score
116
Trophy points
1,343
Location
Sri Lanka
Activity points
3,551
Hi vishy71,

If timer increment is faster than LCD writing speed, all the values in timer-register can not be written on LCD.

Your clock source is RA4 means external-clock pulse. Is it ?

Basic problem you have is, How to display register value (binary format) on LCD (as decimal digits) ?
If you use C, it would be very easy as follows

unsigned char i; //Decimal-place counter
unsigned char deci_d[3];//array for decimal-digits
unsigned int value; //value to be converted (8bit)

void main()
{

for (i=0; i<3; i++) //for 3 digits
{
deci_d= value % 10; // get mod of 10
value=value /10; // value div by 10
}

}

deci_d array will have ones, tens, hundreds. These should be converted to ASCII letters then can be shown on LCD.

Does this solve your problem ?
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating

g_shyam1682

Full Member level 4
Joined
Jan 11, 2010
Messages
206
Helped
53
Reputation
106
Reaction score
43
Trophy points
1,308
Location
Udaipur-Rajshan-India
Activity points
2,551
Hi friend

I wanna show 65 on LCD not a! how can I do it!

for show 65 on LCD,
My code is below in C language,

/**************************************/

unsigned int Value = 65;
unsigned char TempA = 0, TempB = 0;

TempA = Value / 10; //Here TempA = 6
TempA += 0x30; //Here 6 Converted in ASCII Value of 6

TempB = Value % 10; //Here TempB = 5
TempB += 0x30; //Here 5 Converted in ASCII Value of 5

Then Send TempA and TempB variable to LCD for display 65 on LCD

Hope this is help you
Shyam
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating

vishy71

Full Member level 2
Joined
Dec 16, 2010
Messages
126
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Iran
Activity points
2,295
ohhhhhhh thaaaaaaaaanks!

but friends can you convert this codes to assembly please? because I work with MPLAB assembly!

Basic problem you have is, How to display register value (binary format) on LCD (as decimal digits) ?
yes this is my problem!also convert HEX to ASC to show on LCD!for example I wanna show the result of Ulterasonic on LCD!
at the end let me say in this way:
I wanna show NUMBER on LCD!NUMBER is in the varibale!for example I wanna show the value of x register on LCD but numberial not Binary or HEX or ASK!number!
and I wanna do this in assembly language!

thanks for all
 

DineshSL

Advanced Member level 1
Joined
May 10, 2010
Messages
403
Helped
121
Reputation
242
Reaction score
116
Trophy points
1,343
Location
Sri Lanka
Activity points
3,551
Hi,

You may write above code in micro-c (set project details based on your PIC circuit). After you build it you can "view" assembly code there.
Also you may download a tool for asmtranslator; fed the generated lst to it and convert to mplab compatible assembly code. You have to carefully go through it to find variables. Then insert it to your code.

wish you success !
 
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating

vishy71

Full Member level 2
Joined
Dec 16, 2010
Messages
126
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Iran
Activity points
2,295
Hi
thanks! I try it before but It'ssssssssssssss really hard!
 

vishy71

Full Member level 2
Joined
Dec 16, 2010
Messages
126
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Iran
Activity points
2,295
processor p16f84a
include <p16f84a.inc>
__config _XT_OSC & _CP_OFF & _PWRTE_OFF & _WDT_OFF


;*************************************************************************************************
;*********************************************8 bit LCD*******************************************
;*************************************************************************************************
;/////////////////////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////////////////////
;
; Amin Aghakhani
; **broken link removed**
; vishtaspahoraii@yahoo.com
;
;/////////////////////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////////////////////
;
; LCD port ----------> portb
; LCD_RS ----------> RA0
; LCD_E ----------> RA1
;
;/////////////////////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////////////////////
;*************************************************************************************************
;*********************************************8 bit LCD*******************************************
;*************************************************************************************************

cblock 0x0c
Reg_1
Reg_2
Reg_3
Reg_4
endc
tmp equ 0x10
clm equ 0x25
LCD_port equ 0x06

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Main codes%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

bsf 0x03,5
clrf 0x86
clrf 0x85
bsf 0x85,2
movlw b'11111000'
movlw OPTION_REG
bcf 0x03,5
clrf 0x06
clrf 0x05
call delay50ms
call LCD_init
;Write Debounce on LCD
movlw .68
call LCD_CHR
movlw .101
call LCD_CHR
movlw .98
call LCD_CHR
movlw .111
call LCD_CHR
movlw .117
call LCD_CHR
movlw .110
call LCD_CHR
movlw .99
call LCD_CHR
movlw .101
call LCD_CHR
movlw .58
call LCD_CHR
;End of writing

count
btfsc 0x05,2
goto sss
goto $-2

sss
incf tmp,1
movlw 0xc0
addlw 0x09
call LCD_CMD
movf tmp,0
call LCD_CHR ;stooooooooop here! I wanna show number not character!plz help!
btfsc 0x05,2
goto $-1
goto count

;*******************************************************************************************************
;*******************************************************************************************************
;*******************************************************************************************************

LCD_init
movlw 0x30
call LCD_CMD
movlw 0x30
call LCD_CMD
movlw 0x30
call LCD_CMD

movlw 0x38
call LCD_CMD

movlw 0x0c
call LCD_CMD

movlw 0x01 ;clear display
call LCD_CMD

call delay1500us
return

LCD_CMD
movwf LCD_port
bsf 0x05,0
call delay800us
bcf 0x05,0
call delay800us
return

LCD_CHR
movwf LCD_port
bsf 0x05,1
bsf 0x05,0
call delay800us
bcf 0x05,0
bcf 0x05,1
call delay800us
retrun
;=================================================================================================
;=========================================Delay routines==========================================
;=================================================================================================

delay1500us
movlw .241
movwf Reg_1
movlw .2
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
nop
return

delay800us
movlw .8
movwf Reg_1
movlw .2
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
return

delay50ms
movlw .238
movwf Reg_1
movlw .65
movwf Reg_2
decfsz Reg_1,F
goto $-1
decfsz Reg_2,F
goto $-3
nop
return
end
 

DineshSL

Advanced Member level 1
Joined
May 10, 2010
Messages
403
Helped
121
Reputation
242
Reaction score
116
Trophy points
1,343
Location
Sri Lanka
Activity points
3,551
  • Like
Reactions: vishy71

    vishy71

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top