Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

i2c issues

Status
Not open for further replies.
I need to see your main.... You appear to have a buffer

DisplayText[25][];

I can't tell how big this is but if "buffer" is 10 chars why would you need 25 of them.. That would be 255 bytes and overrun the stack!
 
Ian Rogers the i2c.c is actually is the main, the main just calls these functions.

C:
void main(void)
{
    // Initialize the device
    SYSTEM_Initialize();
    display_Initialize();
   
    putsLCD("HELLO WORLD");

    while (1)
    {
        // Add your application code
    }
}

I did work on it yesterday and came up with:

C:
void putsLCD (char *buffer)
{
    int Len = 0;
    char DisplayText[10][10];

    while (*buffer != NULL)               //count the char
    {
        buffer++;
        Len++;
    }
   
    buffer = DisplayText;
   
    data = (char*)DisplayText;
   
   
    address = LCD;
    i2c_writeNBytes (address, DisplayText, Len);
}
 
Why do you need 10 strings??? I normal allocate enough for 1 then reuse it as it's only needed in one place..

If you need that amount of static data, then make it global then the stack won't destroy it..

Here's how it works:-
1537809704060.png



then the subroutine address and return byte and possibly 50 bytes.. if you call another routine the stack will already be at 68 bytes... You must also think about interrupts..... they also need storage.... Once the stack is depleted it starts to eat away at ram.. Its the programmes job to manage the stack...
 
I am now working on mcu-mcu. The master sends out the slave read address and then the register address, is the register address the actual memory address or is this something that I have to define. For instance if I want the result from the adc @ 0x06 is the slave going to return what is stored at that address?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top