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.

Why doesn't my display routine work properly?

Status
Not open for further replies.
So when you have a pointer that points to a block of memory, such as an array or a part of an array, you can treat that pointer ``as if'' it were an array, using the convenient notation. In other words, at the beginning of this section when we talked about *ip, *(ip+1), *(ip+2), and *(ip+i), we could have written ip[0], ip[1], ip[2], and ip. As we'll see, this can be quite useful (or at least convenient).



Absolutely not correct.



I have to disagree, this is standard C behavior.
Can you try the following, they work fine for me in keil uvision (ARM version) and copy the content of array1 to array2


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
char my_array1[] = "test";
char my_array2[5];
char *my_char_p;
 
 
int main(void)
{
    my_array2[0] = my_char_p[0];
    my_array2[1] = my_char_p[1];
    my_array2[2] = my_char_p[2];
    my_array2[3] = my_char_p[3];
    my_array2[3] = my_char_p[4];
 
    while(1);
}





Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
char *my_char_p = "test";
char my_array2[5];
char *my_char_p;
 
 
int main(void)
{
    my_array2[0] = my_char_p[0];
    my_array2[1] = my_char_p[1];
    my_array2[2] = my_char_p[2];
    my_array2[3] = my_char_p[3];
    my_array2[3] = my_char_p[4];
 
    while(1);
}



Alex
 

I'm really grateful for your help but nothing you put here seems to work for me...

So I decided to do it in another completely manner but I also get a problem this way, although it's the nearest thing to get it working that I have, in fact I see the problem as even more weird, maybe you can help me with this.

This is the code:

Code:
#include <p18cxxx.h>
#include "xlcd.h"
 
 
#pragma config OSC=INTIO67, FCMEN=ON, WDT=OFF, IESO=ON, XINST=OFF, LVP=OFF
 
char XLCD_Disp1[] = "1234567890";
char XLCD_Disp2[] = " PIC_UC       ";
 
 
void main(void)
{
unsigned char config=0xFF,i=0,addr=0,data=0;
ADCON1 = 0xFF;
 
TRISD = 0;
PORTD = 0;	
TRISB = 0;				// Port,pin direction configuration
PORTB = 0;
TRISC = 0;
PORTC = 0;
TRISCbits.TRISC7 = 1;  // make sure this pin is input
TRISE=0;
 
	config = FOUR_BIT  & LINES_5X7;
//********  Configure LCD for four line communication and 5X7 line display *********************************
	OpenXLCD(config);		
		busylcd();		//wait untill LCD controller is busy
 
//*********** Set the starting address in the LCD RAM for display. This determines the location of display ********	
	SetDDRamAddr(0x80);
		busylcd();		//wait untill LCD controller is busy
	putsXLCD(XLCD_Disp1);			//Display string of text
		busylcd();		//wait untill LCD controller is busy
 
//********** Set the address in second line for display ****************************************************		
	SetDDRamAddr(0xC1);
		busylcd();		//wait untill LCD controller is busy
	putsXLCD(XLCD_Disp2);					//Display string of text
		busylcd();		//wait untill LCD controller is busy
	putcXLCD(0x5F);					//dsiplay some chrecter
	 	busylcd();		//wait untill LCD controller is busy
 
	SetDDRamAddr(0x20);
		busylcd();		//wait untill LCD controller is busy
 
	while(1);					//end of program		
 
}

void busylcd(void)
{
	LCDDelay();
	LCDDelay();
	LCDDelay();
}
 
void LCDDelay(void)
{
 
 
int i=0;
for (i=0;i<250;i++);
 
}

But the display just shows on first line "1" and on the second "P", nothing more.

Could you please tell me what might be failing? I don't have an idea and I'm seriously going nuts with this thing, so I'd appreciate it a lot.

Thanks.
 

that might be the 1 from the initial string and the P from the next. tery to do it in a loop
Code:
 unsigned int i;
     while(dataString[i]!='\0')
	 {
          putsXLCD(XLCD_Disp1[i]);
       	i++;
	}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top