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.

[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,296
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!
 

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
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?
 

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
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
thanks! but TMR0 value is hex! I wanna convert it to ask or decimal!
what instruction must I use?
 

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
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
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!
 

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
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
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
 

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
Hi
thanks! I try it before but It'ssssssssssssss really hard!
 

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
 

  • 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

Back
Top