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.

Displaying 1-100 in 16X2 LCD using 8051 assembly language

Status
Not open for further replies.

netdeamon

Newbie level 6
Joined
Jun 7, 2013
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,396
I am using timer in 8051. Somebody told me that timer control (measuring time between two pulses and such) in assembly is more accurate than using timer in C.

So now I am struck with displaying the number 1-100 using assembly.
I can do 1-9.
But what should be my logic to display 1-100 in assembly?
I am using 89v51RD2 phillips chip.
 

The behavior or accuracy of the timer/capture/compare module is independent of the language used to configure the module.

It is true, Assembly Language is more deterministic especially concerning delays, latency, ISR times, etc.

However, once the timer module and its associated features have been configured, it operates independently of the firmware/app currently running.

The pulse interval obtained by timer module is indifferent to whether it was configured from firmware derived from Assembly Language or C Language.


As to your LCD routines, the technique to display a single digit/characters is not much different from displaying a string of digits/characters.

The following tutorial covers LCD routines in both C and Assembly Languages and provides source code in both:

LCD interfacing with Microcontrollers tutorial


BigDog
 

However, once the timer module and its associated features have been configured, it operates independently of the firmware/app currently running.

The pulse interval obtained by timer module is indifferent to whether it was configured from firmware derived from Assembly Language or C Language.

BigDog

What I am doing is starting the counter at one pulse and stopping it at another.
And I calculate the time duration between it.
So it dosent matter if I write the code in C or in assembly? The time duration will remain same?
 

What I am doing is starting the counter at one pulse and stopping it at another.
And I calculate the time duration between it.
So it dosent matter if I write the code in C or in assembly? The time duration will remain same?

If you utilize the timer capture mode, there will be NO difference.

Once the Timer2 is properly configure in Capture Mode, when a transition occurs on T2EX, the value of timer2 is immediately stored in RCAP2L and RCAP2H and an interrupt is generated.

The interrupt can be serviced by either an ISR written in C or Assembly Language, which ever is more convenient and does not affect the value stored in RCAP2L and RCAP2H.

Timer is indifferent to being configured by firmware generated from C or Assembly Language.

Reference: **broken link removed**, Section: 6.5.1 Capture mode, Page: 33
6.5.1 Capture mode
In the Capture mode there are two options which are selected by bit EXEN2 in T2CON. If
EXEN2 = 0 Timer 2 is a 16-bit timer or counter (as selected by C/T2 in T2CON) which
upon overflowing sets bit TF2, the Timer 2 overflow bit.

This bit can be used to generate an interrupt (by enabling the Timer 2 interrupt bit in the
IEN0 register). If EXEN2 = 1, Timer 2 operates as described above, but with the added
feature that a 1-to-0 transition at external input T2EX causes the current value in the
Timer 2 registers, TL2 and TH2, to be captured into registers RCAP2L and RCAP2H,
respectively.

In addition, the transition at T2EX causes bit EXF2 in T2CON to be set, and EXF2 like
TF2 can generate an interrupt (which vectors to the same location as Timer 2 overflow
interrupt). The Timer 2 interrupt service routine can interrogate TF2 and EXF2 to
determine which event caused the interrupt.

BigDog
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top