Sponsored By

Sign in to follow this  
krishnasty

Text Scroll On Lcd

Recommended Posts

hey guys..

i wanted certain help from u..can anyone give me a small code in c only to display a scrolling text on any lcd(particularly 16x2)..i am using a arm controller..

thnx..

Share this post


Link to post
Share on other sites

I doubt it. Even if we could we'd need more information; there are thousands upon thousands of ARM µcs.

Share this post


Link to post
Share on other sites

yes, more information

is the LCD direct connected, parallel or serial LCD. are using a LCD interface. there is no such thing as code that will work on any LCD, as all LCD's or most, use different pin outs.

and which ARM

PIC code could be like this

extern unsigned char delayus_variable;

#if (PIC_CLK == 4)
#define dly125n please remove; for 32Mhz+ only
#define dly250n please remove; for 16Mhz+ only
#define dly500n please remove; for 8Mhz+ only
#define dly1u asm("nop")
#define dly2u dly1u;dly1u
#endif

#if (PIC_CLK == 8)
#define dly125n please remove; for 32Mhz+ only
#define dly250n please remove; for 16Mhz+ only
#define dly500n asm("nop")
#define dly1u dly500n;dly500n
#define dly2u dly1u;dly1u
#endif

#if (PIC_CLK == 16)
#define dly125n please remove; for 32Mhz+ only
#define dly250n asm("nop")
#define dly500n dly250n;dly250n
#define dly1u dly500n;dly500n
#define dly2u dly1u;dly1u
#endif

#if (PIC_CLK == 20)
#define dly200n asm("nop")
#define dly400n dly250n;dly250n
#define dly2u dly400n;dly400n;dly400n;dly400n;dly400n
#endif

#if (PIC_CLK == 32)
#define dly125n asm("nop")
#define dly250n dly125n;dly125n
#define dly500n dly250n;dly250n
#define dly1u dly500n;dly500n
#define dly2u dly1u;dly1u
#endif

#if ((PIC_CLK != 4) && (PIC_CLK != 8) && (PIC_CLK != 16) && (PIC_CLK != 32))
please define pic_clk
#endif

//delay routine

#if PIC_CLK == 4
#define DelayDivisor 4
#define WaitFor1Us asm("nop")
#define Jumpback asm("goto $ - 2")
#endif

#if PIC_CLK == 8
#define DelayDivisor 2
#define WaitFor1Us asm("nop")
#define Jumpback asm("goto $ - 2")
#endif

#if PIC_CLK == 16
#define DelayDivisor 1
#define WaitFor1Us asm("nop")
#define Jumpback asm("goto $ - 2")
#endif

#if PIC_CLK == 32
#define DelayDivisor 1
#define WaitFor1Us asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop")
#define Jumpback asm("goto $ - 6")
#endif

#if ((PIC_CLK != 4) && (PIC_CLK != 8) && (PIC_CLK != 16) && (PIC_CLK != 32))
please define pic_clk
#endif

#define DelayUs(x) { \
delayus_variable=x/DelayDivisor; \
WaitFor1Us; } \
asm("decfsz _delayus_variable,f"); \
Jumpback;

/*

timeouts:

C code for testing with unsigned chars & ints, using simulator for verification:

unsigned char timeout_char;
unsigned int timeout_int;
volatile unsigned char x=0,y=1; //good practice, make main/int vars volatile

while(1)
{
//for max 491512us timeout @ 8Mhz
//for max 245756us timeout @ 16Mhz
timeout_int=timeout_int_us(500);
b;
while(timeout_int-- >= 1)
{
if (x==y) break; //typical overhead for checking ring buffer
}
b;

//for max timeout of 1147us @ 8Mhz
//for max timeout of 573us @ 16Mhz
timeout_int=timeout_char_us(500);
b;
while(timeout_char-- >= 1)
{
if (x==y) break; //typical overhead for checking ring buffer
}
b;

}

Time taken: optimisations on: 9cyc/number loop, 4.5us @ 8Mhz
with extra check ie: && (RB7==1), +3cyc/number loop, +1.5us @ 8Mhz

Formula: rough timeout value = (<us desired>/<cycles per loop>) * (PIC_CLK/4.0)

*/

#define LOOP_CYCLES_CHAR 9 //how many cycles per loop, optimizations on
#define timeout_char_us(x) (unsigned char)((x/LOOP_CYCLES_CHAR)*(PIC_CLK/4.0))

#define LOOP_CYCLES_INT 16 //how many cycles per loop, optimizations on
#define timeout_int_us(x) (unsigned int)((x/LOOP_CYCLES_INT)*(PIC_CLK/4.0))

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this