Text Scroll On Lcd


Recommended Posts

  • 2 weeks later...

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...