1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

C programming question - using in arduino

Discussion in 'Programming & Webmastering' started by shuggans, Jan 20, 2013.

  1. shuggans

    Joined:
    Dec 22, 2007
    Messages:
    175 (0.07/day)
    Thanks Received:
    7
    Location:
    Central Nebraska
    Hey all - my friend and I are trying to get this code to work, but the compiler is giving us the error: "initializer fails to determine size of '__c'".

    We are TRYING to create a variable, then assign it the value of whatever is read on the rx serial port pin, then printf that variable.

    Code:
    #include "hardware.h"
    
    
    // Initialise the hardware
    void appInitHardware(void) {
    	initHardware();
    }
    // Initialise the software
    TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
    	return 0;
    }
    // This is the main loop
    TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {
    
    if(myUart.isRxBufferEmpty() == false) {
    	int InstreamData = myUart.read();
    	if(InstreamData != 0){
    		PRINTF(stdout,InstreamData);
    	}
    }
    	return 0;
    }
    
    Last edited: Jan 20, 2013
  2. de.das.dude

    de.das.dude Pro Indian Modder

    Joined:
    Jun 13, 2010
    Messages:
    7,587 (4.92/day)
    Thanks Received:
    1,982
    i think the size of your code is greater than what the chip you have can take
    also where is nothing in the program? all of them are comments?


    i may be wrong, i dont have much arduino knowledge. but no one replied so here i am.
  3. shuggans

    Joined:
    Dec 22, 2007
    Messages:
    175 (0.07/day)
    Thanks Received:
    7
    Location:
    Central Nebraska
    These chips can handle WAYYY more code than this :p. The problem I dont believe its even related to arduino or the chip at all.. this is a c compiler giving the error before it ever hits the chip
  4. de.das.dude

    de.das.dude Pro Indian Modder

    Joined:
    Jun 13, 2010
    Messages:
    7,587 (4.92/day)
    Thanks Received:
    1,982
    HTML:
    #include <hardware.h>
    
    
    // Initialise the hardware
    void appInitHardware(void)
    {
    	initHardware();
    }
    // Initialise the software
    TICK_COUNT appInitSoftware(TICK_COUNT loopStart)
    {
    	return 0;
    }
    // This is the main loop
    TICK_COUNT appControl(LOOP_COUNT loopCount,TICK_COUNT loopStart)
    {
    
    if(myUart.isRxBufferEmpty()==false) 
               {
    	        int InstreamData=myUart.read();
    	        if(InstreamData!=0)
                       {
    		printf(stdout,InstreamData);
    	        }
               }
    	return 0;
    }

    try this. copy paste it.

    ithink i may have fixed a couple of grammatical errors. have you tried running it in borland C ?
  5. W1zzard

    W1zzard Administrator Staff Member

    Joined:
    May 14, 2004
    Messages:
    14,794 (3.93/day)
    Thanks Received:
    11,498
    Mentioning the line number for the error would make things much easier :)

    You are using printf wrong. Parameter 1 is a format string, not a file handle (looking for fprintf?)

    http://playground.arduino.cc/Main/Printf

    also see the comment on that page about PSTR()
    de.das.dude says thanks.
  6. shuggans

    Joined:
    Dec 22, 2007
    Messages:
    175 (0.07/day)
    Thanks Received:
    7
    Location:
    Central Nebraska
    line 23: the printf error. I think it's because we're tryign to call a dynamic value

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page