Jump to content
Badejavu

Help Boost C Pointer Array Not Working!

Recommended Posts

Badejavu    0

Hello can anyone help with the codes below.I want to display the contents of a pointer array by loading it into another buffer array on an I2C lcd.when i do this, it does not get the contents of the font map on my logic analyser.However if i load the buffer with test (1 to 6) it works.I also tried writing the *N4 [ ] array directly to the I2C sspbuf and it works.I cannot seem to understand why( m_temp_buf = N4; )does not work.

Thanks

 

 

//////////////////// MY CODE ///////////////////////////////////////////////

 

rom char *N4 = { 0xfe, 0x2a, 0xc5, 0x00, 0xa2, 0xe7 }; // LCD font map for the number " 4 "

char m_temp_buf[6] // buffer to hold 6 bytes for the number "4"

 

/*char m_temp_buf[ ] = {1,2,3,4,5,6};*/ // i tested the buffer with to see this data on my logic analyser and it worked

void GetSegbytes(char); // function to get bytes from the array "N4"

void WritetoLcd(char); //I2C function to write the bytes to an LCD

 

 

 

void main() // main start

{

 

WritetoLcd(4); // write number " 4 " to Lcd

} //main ends

 

 

///////Functions//////////////////////////////////

void GetSegbytes(char num)

{

char i;

switch(num)

{

case '4':

for(i =0; i < 6; i++)

m_temp_buf = N4; //PROBLEM:DOES NOT LOAD VALUES IN ( *N4) ARRAY TO (m_temp_buf)

break;

}

}

 

void WritetoLcd(char number)

{

 

GetSegbytes(number);

 

I2C_start(); //start

for(char i1=0;i1<6;i1++) //send 6 bytes from buffer to I2C

{

sspbuf = m_temp_buf[i1]; //write 6 bytes via I2C ,IF I REPLACE (m_temp_buf[i1]) WITH (N4 ) IT WORKS WELL

while (!pir1.SSPIF);

pir1.SSPIF=0;

}

I2C_stop(); // stop

}

Share this post


Link to post
Share on other sites
Reynard    0

Did you add the semicolon in your code ?

 

char m_temp_buf[6]; // buffer to hold 6 bytes for the number "4"

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites
Badejavu    0

Hi Reynard, yes…I did . the code compiles.

m_temp_buf = N4;

 

The array elements of N4 do not load in the m_temp_buf array to be sent over I2C.This is where the problem is.I do not know if it is an issue with the compiler?

Share this post


Link to post
Share on other sites
Reynard    0

Doh! I didn't spot that one.

 

The case is expecting the ascii character '4' but the function WritetoLcd is being past the value of 4.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum 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...

×