Jump to content

Help Boost C Pointer Array Not Working!


Recommended Posts

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

}

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...
×
×
  • Create New...