Tulsanus Hurricanus Digitalus Mus Controller EDU Processor 10 MIPS Variable space: 2K SRAM Program space: 32K FLASH Serial port Interrupts Timers Direct control of the hardware
C Concepts " Modular " Powerful " Industry standard " Fast and efficient
Programming in dialect of C No native floating point math. No built in trig functions. optional Assembly Macros GetData() PutData() Get_Analog_Value() function Digital I/O (user chooses) Sixteen 10-bit analog inputs
One project, many files .c-Source Files .h-Header Files .lib-Library Files .lkr-Linker Scripts Edit the.c and.h files Compile Link
Variables unsigned char wheel_count; /* range: 0 to 255 */ char wheel_count; /* range: -128 to 127 */ unsigned int wheel_count; /* range: 0 to */ int wheel_count; /* range: to */
unsigned int Doubled_Number (unsigned int num2double) { unsigned int result; result = 2 * num2double; return result; } Sample Function LOCAL VARIABLES CODE TO EXECUTE RETURN VALUE Sample Function
Pre-Processor Directive The # symbol denotes a pre-processor directive that is evaluated before the compiler takes over. #include ifi_aliases.h MUST be in left-most column!
#define preprocessor directive #define identifier replacement-text occurrences of identifier is replaced by replacement- text before compilation " Symbolic constants #define PI all subsequent occurrences of symbol constant PI are replaced with #define FIELD_WIDTH 125 #define FIELD_LENGTH 300
#define preprocessor directive #define macro-identifier replacement-text occurrences of macro-identifier is replaced by replacement-text before compilation " Macros #define CIRCLE_AREA(x) (PI*(x)*(x)) when CIRCLE_AREA(x) appears: " The value of x is substituted for x " Then the macro is expanded #define macro-identifier replacement-text occurrences of macro-identifier is replaced by replacement-text before compilation " Macros #define CIRCLE_AREA(x) (PI*(x)*(x)) when CIRCLE_AREA(x) appears: " The value of x is substituted for x " Then the macro is expanded
#define preprocessor directive #define CIRCLE_AREA(x) (PI*(x)*(x)) area= CIRCLE_AREA(7) ; // becomes: area= ( * (7) *(7)); area = CIRCLE_AREA(rd +2); //becomes: area = ( * (rd+2)*(rd+2)); #define FIELD_PERIMETER FIELD_WIDTH*2+FIELD_LENGTH*2 #define CIRCLE_AREA(x) (PI*(x)*(x)) area= CIRCLE_AREA(7) ; // becomes: area= ( * (7) *(7)); area = CIRCLE_AREA(rd +2); //becomes: area = ( * (rd+2)*(rd+2)); #define FIELD_PERIMETER FIELD_WIDTH*2+FIELD_LENGTH*2
Output in C " printf("pwM01 = ",pwd, \n)