Help for the Embedded -C for KIEL (Switch Program code)

Discussion in 'Embedded Systems and Microcontrollers' started by mkbutan, Aug 2, 2012.

  1. mkbutan

    Thread Starter Senior Member

    Sep 30, 2008
    270
    16
    I am reading the book (PDF) Embedded - C by Michael J.
    (these are not my coed's I have just coped from the above book)
    I have Keil μVer -4 but these code's give error as below
    --------------------
    Build target 'Target 1'
    linking...
    *** ERROR L127: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL: ?C_START
    MODULE: STARTUP.obj (?C_STARTUP)
    *** ERROR L128: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL: ?C_START
    MODULE: STARTUP.obj (?C_STARTUP)
    ADDRESS: 100080AH
    Program Size: data=9.0 xdata=0 const=0 code=15
    Target not created
    ------------------
    I am not able to run these coed in simulator pl help what's going wrong?
    the coed are as follows
    Code ( (Unknown Language)):
    1.  
    2. #include<reg52>
    3. //connect switch to this pin
    4. sbit switch_pin = p1^0;
    5. //display count (binary) on this port
    6. #define count_port p3
    7. //return values from switch_get_input()
    8. #define switch_not_pressed (bit) 0
    9. #define switch_prssed (bit) 1
    10. //function prototypes
    11. void switch_input(void);
    12. bit switch_get_input(const unsigned char);
    13. void display_count_init(void);
    14. void display_count_update(const unsigned char);
    15. void delay_loop_wait(count unsigned int);
    16. void main(void)
    17. {
    18. unsined char switch_presses = 0;
    19. // init function
    20. switch_init();
    21. pisplay_count_init();
    22. while(1)
    23. {
    24. if (switch_get_input(30) == switch_pressed)
    25. {
    26. switch_presses++;
    27. }
    28.  
    29. display_count_update(switch_presses);
    30. }
    31. }
    32. void switch_init(void)
    33. {
    34. switch_pin = 1;
    35. }
    36. bit switch_get_input(count unsigned char debounce_period)
    37. {
    38. bit return_value = switch_not_pressed;
    39. if (switch_pin == 0)
    40. {
    41. //switch is pressed
    42. //debounce - just wait...
    43. delay_loop_wait(debounce_period);
    44. //check switch again
    45. if (switch_pin ==0)
    46. {
    47. //wait until the switch is relised.
    48. while(switch_pin ==0);
    49. return_value = switch_pressed;
    50. }
    51. }
    52. //now (finelly) return switch value
    53. return returen_value;
    54. }
    55. void display_count_init(void)
    56. {
    57. count_port = 0x00;
    58. }
    59. void display_count_update(const unsigned char count)
    60. {
    61. count_port = count;
    62. }
    63. void delay_loop_wait(const unsigned int delay_ms)
    64. {
    65. unsigned int x, y;
    66. for (x = 0; x<=delay_ms;x++)
    67. {
    68. for (y = 0; y<=120; y++);
    69. }
    70. }
    71.  
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,606
    I don't use that compiler so sorry I can't give you any exact help. "C_StARTUP" sounds like some code all C compilers are supposed to insert into your project to do some housekeeping functions, such as define the variables, set up the stack, and other "behind the scene" things.

    HOW that module gets linked into your code I do not know, it would perhaps be in the build settings, but I don't have any idea how your compiler sets this up.
     
    mkbutan likes this.
  3. Arm_n_Legs

    Active Member

    Mar 7, 2007
    183
    10
    When the compiler ask if you wish to add the startup code, click Yes.
     
Loading...