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

Discussion in 'The Projects Forum' 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. #include<reg52>
    2. //connect switch to this pin
    3. sbit switch_pin = p1^0;
    4. //display count (binary) on this port
    5. #define count_port p3
    6. //return values from switch_get_input()
    7. #define switch_not_pressed (bit) 0
    8. #define switch_prssed (bit) 1
    9. //function prototypes
    10. void switch_input(void);
    11. bit switch_get_input(const unsigned char);
    12. void display_count_init(void);
    13. void display_count_update(const unsigned char);
    14. void delay_loop_wait(count unsigned int);
    15. void main(void)
    16. {
    17. unsined char switch_presses = 0;
    18. // init function
    19. switch_init();
    20. pisplay_count_init();
    21. while(1)
    22. {
    23. if (switch_get_input(30) == switch_pressed)
    24. {
    25. switch_presses++;
    26. }
    27.  
    28. display_count_update(switch_presses);
    29. }
    30. }
    31. void switch_init(void)
    32. {
    33. switch_pin = 1;
    34. }
    35. bit switch_get_input(count unsigned char debounce_period)
    36. {
    37. bit return_value = switch_not_pressed;
    38. if (switch_pin == 0)
    39. {
    40. //switch is pressed
    41. //debounce - just wait...
    42. delay_loop_wait(debounce_period);
    43. //check switch again
    44. if (switch_pin ==0)
    45. {
    46. //wait until the switch is relised.
    47. while(switch_pin ==0);
    48. return_value = switch_pressed;
    49. }
    50. }
    51. //now (finelly) return switch value
    52. return returen_value;
    53. }
    54. void display_count_init(void)
    55. {
    56. count_port = 0x00;
    57. }
    58. void display_count_update(const unsigned char count)
    59. {
    60. count_port = count;
    61. }
    62. void delay_loop_wait(const unsigned int delay_ms)
    63. {
    64. unsigned int x, y;
    65. for (x = 0; x<=delay_ms;x++)
    66. {
    67. for (y = 0; y<=120; y++);
    68. }
    69. }  
     
Loading...