Home

032 Manual - Digi-Key

image

Contents

1. Flag Meaning abs Psect is absolute bit Psect holds bit objects class name Specify class name for psect delta size Size of an addressing unit global Psect is global default isa Specify Instruction Set Architecture limit address Upper address limit of psect local Psect is not global ovrld Psect will overlap same psect in other modules pure Psect is to be read only reloc boundary Start psect on specified boundary size max Maximum size of psect space area Represents area in which psect will reside with psect Place psect in the same page as specified psect e abs defines the current psect as being absolute i e it is to start at location 0 This does not mean that this module s contribution to the psect will start at 0 since other modules may contribute to the same psect e The bit flag specifies that a psect hold objects that are 1 bit long Such psects have a scale value of 8 to indicate that there are 8 addressable units to each byte of storage e The class flag specifies a class name for this psect Class names are used to allow local psects to be referred to by a class name at link time since they cannot be referred to by their own name Class names are also useful where psects need only be positioned anywhere within a range of addresses rather than at one specific address e The delta flag defines the size of an addressing unit In other words the number of bytes covered for an increment in
2. Control Meaning Format COND Include conditional code in the listing COND EXPAND Expand macros in the listing output EXPAND INCLUDE Textually include another source file INCLUDE lt pathname gt LIST Define options for listing output LIST lt listopt gt lt listopt gt NOCOND Leave conditional code out of the listing NOCOND NOEXPAND Disable macro expansion NOEXPAND NOLIST Disable listing output NOLIST PAGE Start a new page in the listing output PAGE SUBTITLE Specify the subtitle of the program SUBTITLE lt subtitle gt TITLE Specify the title of the program TITLE lt title gt SIGNAT directive is used by the HI TECH C compiler to enforce link time checking of C function prototypes and calling conventions Use the SIGNAT directive if you want to write assembly language routines which are called from C For example SIGNAT _fred 1049 will associate the signature value 8192 with the symbol _fred If a different signature value for _fred is present in any object file the linker will report an error 4 3 11 Assembler Controls Assembler controls may be included in the assembler source to control assembler operation such as listing format These keywords have no significance anywhere else in the program The control is invoked by the directive OPT followed by the control name Some keywords are followed by one or more parameters For example OPT EXPAND A list of keywords is
3. 52 2 6 28 GETOPTION app file Get Command line Options 52 2 6 29 HELP lt p9ption gt Display Help s c i 0 AG ee ee 52 2 6 30 IDE type Specify the IDE being used 52 2 6 31 INTERRUPTS suboption lt suboption gt Specify the Interrupts Scheme 52 2 6 32 ISA lt type gt Specify the Instruction Set Architecture 54 2 6 33 LANG language Specify the Language for Messages 54 2 6 34 MEMMAP file Display Memory Map 55 2 6 35 MSGDISABLE messagelist Disable Warning Messages 55 2 6 36 MSGFORMAT format Set Advisory Message Format 55 2 6 37 NODEL Do not remove temporary files 55 20 38 N0EXEC Don t Execute Compiler s angeru poe Behe yd dees 55 2 6 39 OBJDIR path Specify a directory for Object files 55 2 6 40 OPT lt t ype gt Invoke Compiler Optimizations 56 2 6 41 OUTDIR path Specify a directory for Output files 56 2 6 42 OUTPUT t ype Specify Output File Type 56 20 43 BASSI Completo P Code os scsi Ee e eS 57 2 6 44 PRE Produce Preprocessed Source Code o oo oo 57 2 645 PROTO Generate Prototypes o o os e teceu casos rss da 58 2 6 46 RAM lo hi lt lo hi gt Specify Additional RAM Ranges 59 2 6 47 ROM lo hi lt lo hi gt tag Specify Additional ROM Ranges 59 2 6 48 RUNTIME type Specify Run
4. I This option forces listing of macro expansions and unassembled conditionals which would other wise be suppressed by a NOLIST assembler control The L option is still necessary to produce a listing 111 Assembler Options Macro Assembler Llistfile This option requests the generation of an assembly listing file If 1ist file is specified then the listing will be written to that file otherwise it will be written to the standard output An assembly listing file contains additional fields such as the address and opcode fields which are not part of the assembly source syntax hence these files cannot be passed to the assembler for compilation See the assembler A option for generating processed assembly source files that can be used as source files in subsequent compilation O This requests the assembler to perform optimization on the assembly code Note that the use of this option slows the assembly process down as the assembler must make an additional pass over the input code Debug information for assembler code generated from C source code may become unreliable Ooutfile By default the assembler determines the name of the object file to be created by stripping any suffix or extension i e the portion after the last dot from the first source filename and appending obj The 0 option allows the user to override the default filename and specify a new name for the object file Pprocessor This option defines the processor which
5. 985 qualifiers redeclared Parser This function or variable has different qualifiers in different declarations 986 enum member redeclared Parser A member of an enumeration is defined twice or more with differing values Does the member appear twice in the same list or does the name of the member appear in more than one enum list 987 arguments redeclared Parser The data types of the parameters passed to this function do not match its prototype 988 number of arguments redeclared Parser The number of arguments in this function declaration does not agree with a previous declaration of the same function 396 Error and Warning Messages 989 module has code below file base of h Linker This module has code below the address given but the C option has been used to specify that a binary output file is to be created that is mapped to this address This would mean code from this module would have to be placed before the beginning of the file Check for missing psect directives in assembler files 990 modulus by zero in if zero result assumed Preprocessor A modulus operation in a if expression has a zero divisor The result has been assumed to be zero e g define ZERO 0 if FOO ZERO this will have an assumed result of 0 define INTERESTING fendif 991 integer expression required Parser In an enum declaration values may be assigned to the members but the expression must evaluate to
6. Efile Redirect Compiler Errors to a File This option has two purposes The first is to change the format of displayed messages The second is to optionally allow messages to be directed to a file as some editors do not allow the standard command line redirection facilities to be used when invoking the compiler The general form of messages produced with the E option in force is filename line_number message number message string message type If a filename is specified immediately after E it is treated as the name of a file to which all messages errors warnings etc will be printed For example to compile x c and redirect all errors to x err use the command PICC32 CHIP 32MX360F512L Ex err x c The E option also allows errors to be appended to an existing file by specifying an addition charac ter at the start of the error filename for example PICC32 CHIP 32MX360F512L E x err y c If you wish to compile several files and combine all of the errors generated into a single text file use the E option to create the file then use E when compiling all the other source files For example to compile a number of files with all errors combined into a file called project err you could use the E option as follows PICC32 CHIP 32MX360F512L Eproject err 0 PASS1 main c PICC32 CHIP 32MX360F512L E project err 0 PASS1 partl c PICC32 CHIP 32MX360F512L E project err C asmcode as Section 2 5 has more i
7. FCKSM_CSECME FCKSM_CSECMD FCKSM_CSDCMD Clock Switching and Monitor Selection Configuration FPBDIV_8 Peripheral Bus Clock Divisor Default Value FPBDIV_4 FPBDIV_2 FPBDIV_1 OSCIOFNC_ON OSCIOFNC_OFF CLKO Enable Configuration POSCMD_OFF POSCMD_HS POSCMD_XT POSCMD_EC Primary Oscillator Configuration FSOSCEN_ON FSOSCEN_OFF Secondary Oscillator Enable FNOSC_FRC FNOSC_FRCPLL FNOSC_PRI FNOSC_PIRPLL FNOSC_SOSC FNOSC_LPRC FNOSC_FRCDIV Oscillator Selection 418 Configuration Word 1 DEVCFG1 Configuration Attributes macro __FPLLODIV s FPPLODIV_256 Oscillator Selection creates the config setting for the default postscaler for PLL bits where PLL output is divided by 2 s s is an integer between 0 and 7 FPLLMULT_15 FPLLMULT_16 FPLLMULT_17 FPLLMULT_18 FPLLMULT_19 FPLLMULT_20 FPLLMULT_21 FPLLMULT_24 Initial PLL Multiplier Value FPLLIDIV_1 FPLLIDIV_2 FPLLIDIV_3 FPLLIDIV_4 FPLLIDIV_5 FPLLIDIV_7 FPLLIDIV_10 FPLLIDIV_12 PLL Input Divider Value Configuration Word 2 DEVCFG2 macro USERID id Sets the User ID to id User ID DEVCFG3 419 Configuration Attributes 420 Index macro quote character 129 command file character 21 psect address symbol 144 as files 22 cmd files 157 crf files 50 111 hex files 23 ni files 66 lib files 155 157 nk files 148 st files 49 obj files 1
8. The 32 bit example in Table 3 4 can be calculated manually as follows 72 C Language Features Supported Data Types and Variables Table 3 3 Floating point formats Format Sign biased exponent mantissa IEEE 754 32 bit x XXXX XXXX XXX XXXX XXXX XXXX XXXX XXXX Table 3 4 Floating point format example IEEE 754 Number biased expo 1 mantissa decimal nent TDA6B69Bh 11111011b 1 01001101011011010011011b 2 77000e 37 251 1 302447676659 The sign bit is zero the biased exponent is 251 so the exponent is 251 127 124 Take the binary number to the right of the decimal point in the mantissa Convert this to decimal and divide it by 22 where 23 is the number of bits taken up by the mantissa to give 0 302447676659 Add one to this fraction The floating point number is then given by 1 x 212 x 1 302447676659 1 x 2 126764793256 37 x 1 302447676659 2 77000e 37 Variables may be declared using the float and double keywords respectively to hold values of these types Floating point types are always signed and the unsigned keyword is illegal when specifying a floating point type Types declared as long double will use the same format as types declared as double 3 3 8 Structures and Unions HI TECH C PRO for the PIC32 MCU Family supports st ruct and union types of any size from one byte upwards Structures and unions only differ in the memory offset applied for each membe
9. This is an internal compiler error Contact HI TECH Software technical support with details 631 syntax error at token in SDB file line column Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 632 can t handle address size Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 633 unknown symbol class Cromwell Cromwell has encountered a symbol class in the symbol table of a COFF Microchip COFF or ICOFF file which it can t identify 634 error dumping Cromwell Either the input file to CROMWELL is of an unsupported type or that file cannot be dumped to the screen 635 invalid HEX file on line Cromwell The specified HEX file contains an invalid line Contact HI TECH Support if the HEX file was generated by the compiler 636 checksum error in Intel HEX file on line Cromwell Hexmate A checksum error was found at the specified line in the specified Intel hex file The HEX file may be corrupt 637 unknown prefix in SDB file Cromwell This is an internal compiler warning Contact HI TECH Software technical support with details 364 Error and Warning Messages 638 version mismatch 0x expected Cromwell The input Microchip COFF file wasn t produced using Cromwell 639 zero bit width in Microchip optional header Cromwell The optiona
10. This routine returns a copy of the buffer into which the result is written 282 Library Functions VA_START VA_ARG VA_END Synopsis include lt stdarg h gt void va_start va_list ap parmN type va_arg ap type void va_end va_list ap Description These macros are provided to give access in a portable way to parameters to a function represented in a prototype by the ellipsis symbol where type and number of arguments supplied to the function are not known at compile time The rightmost parameter to the function shown as parmN plays an important role in these macros as it is the starting point for access to further parameters In a function taking variable num bers of arguments a variable of type va_list should be declared then the macro va_start invoked with that variable and the name of parmN This will initialize the variable to allow subsequent calls of the macro va_arg to access successive parameters Each call to va_arg requires two arguments the variable previously defined and a type name which is the type that the next parameter is expected to be Note that any arguments thus accessed will have been widened by the default conventions to int unsigned int or double For example if a character argument has been passed it should be accessed by va_arg ap int since the char will have been widened to int An example is given below of a function taking one integer parameter followed by a number of ot
11. A signed integer less than equal to or greater than zero Note Other C implementations may use a different collating sequence the return value is negative zero or positive i e do not test explicitly for negative one 1 or one 1 261 Library Functions STRNCPY Synopsis include lt string h gt char strncpy char sl const char s2 size_t n Description This function copies a null terminated string s2 to a character array pointed to by s1 At most n characters are copied If string s2 is longer than n then the destination string will not be null terminated The destination array must be large enough to hold the entire string including the null terminator Example include lt string h gt include lt stdio h gt void main void char buffer 256 char sl s2 strncpy buffer Start of line 6 sl buffer s2 end of line strcat s1 s2 printf Length d n strlen buffer printf string s n buffer See Also strcpy streat strlen stremp 262 Library Functions Return Value The destination buffer pointer s1 is returned 263 Library Functions STRPBRK Synopsis include lt string h gt char strpbrk const char sl const char s2 Description The strpbrk function returns a pointer to the first occurrence in string s1 of any character from string s2 or a null pointer if no character from s2 exists in s1
12. A signed number is being assigned or otherwise converted to a larger unsigned type Under the ANSI value preserving rules this will result in the signed value being first sign extended to a signed number the size of the target type then converted to unsigned which involves no change in bit pattern Thus an unexpected sign extension can occur To ensure this does not happen first convert the signed value to an unsigned equivalent e g 332 Error and Warning Messages signed char sc unsigned int ui ul sc if sc contains Oxff ui will contain Oxffff for example will perform a sign extension of the char variable to the longer type If you do not want this to take place use a cast e g ui unsigned char sc 356 implicit conversion of float to integer Parser A floating point value has been assigned or otherwise converted to an integral type This could result in truncation of the floating point value A typecast will make this warning go away double dd int i i dd is this really what you meant If you do intend to use an expression like this then indicate that this is so by a cast i int dd 357 illegal conversion of integer to pointer Parser An integer has been assigned to or otherwise converted to a pointer type This will usually mean you have used the wrong variable but if this is genuinely what you want to do use a typecast to inform the compiler that you want the conversion and t
13. Example include lt stdio h gt include lt string h gt void main void char str This is a string while str NULL printf Ss n str str strpbrk str 1 aeiou Return Value Pointer to the first matching character or NULL if no character found 264 Library Functions STRRCHR STRRICHR Synopsis include lt string h gt char strrchr char s int c char strrichr char s int c Description The strrehr function is similar to the strehr function but searches from the end of the string rather than the beginning i e it locates the last occurrence of the character c in the null terminated string s If successful it returns a pointer to that occurrence otherwise it returns NULL The strrichr function is the case insensitive version of this function Example include lt stdio h gt include lt string h gt void main void char str This is a string while str NULL printf Ss n str str strrchr strt l s See Also strchr strlen strempQ strepy strcat Return Value A pointer to the character or NULL if none is found 265 Library Functions STRSPN Synopsis include lt string h gt size_t strspn const char sl const char s2 Description The strspn function returns the length of the initial segment of the string pointed to by s1 which consists entirely of characters from the string pointed
14. The longjmpO function in conjunction with setjmpQ provides a mechanism for non local goto s To use this facility setimp should be called with a jmp_buf argument in some outer level function The call from setjmpQ will return 0 To return to this level of execution longjmp may be called with the same jmp_buf argument from an inner level of execution Note however that the function which called setjmp must still be active when longjmp is called Breach of this rule will cause disaster due to the use of a stack containing invalid data The val argument to longjmp will be the value apparently returned from the setjmp This should normally be non zero to distinguish it from the genuine setjmp call Example include lt stdio h gt include lt setjmp h gt include lt stdlib h gt jmp_buf jb void inner void longjmp jb 5 void main void int i 222 Library Functions if i setjmp jb printf setjmp returned d n i exit 0 printf setjmp returned 0 good n printf calling inner n inner printf inner returned bad n See Also setimp Return Value The longjmp routine never returns Note The function which called setjmpQ must still be active when longjmp is called Breach of this rule will cause disaster due to the use of a stack containing invalid data 223 Library Functions LTOA Synopsis include lt stdlib h gt
15. found expected in chipinfo file at line Driver This attribute was expected to appear a certain number of times but it did not for this chip 1019 duplicate specification in chipinfo file at line Driver This attribute can only be defined once but has been defined more than once for this chip 1020 unknown attribute in chipinfo file at line Driver The chip configuration file contains an attribute that is not understood by this version of the com piler Has the chip configuration file or the driver been replaced with an equivalent component from another version of this compiler 1021 syntax error reading value in chipinfo file at line Driver The chip configuration file incorrectly defines the specified value for this device If you are modify ing this file yourself take care and refer to the comments at the beginning of this file for a description on what type of values are expected here 398 Error and Warning Messages 1022 syntax error reading range in chipinfo file at line Driver The chip configuration file incorrectly defines the specified range for this device If you are modify ing this file yourself take care and refer to the comments at the beginning of this file for a description on what type of values are expected here 1024 syntax error in chipinfo file at line Driver The chip configuration file contains a syntax error at
16. labels assembly 89 114 118 local 129 labs function 216 language support 37 Idexp function 217 Idiv function 218 LFSR instruction 93 LIBR 155 156 command line arguments 156 error messages 158 listing format 157 long command lines 157 module order 158 librarian 155 command files 157 command line arguments 156 157 error messages 158 listing format 157 long command lines 157 module order 158 libraries adding files to 156 creating 156 deleting files from 156 manager 155 library function __CONFIG 178 abs 179 acos 180 asctime 181 asin 183 assert 184 atan 185 atan2 186 atof 187 atoi 188 atol 189 bsearch 190 ceil 192 cgets 193 cos 195 cosh 196 cputs 197 ctime 198 div 199 eval_poly 200 exp 201 fabs 202 floor 204 fmod 203 frexp 205 ftoa 206 getch 207 429 INDEX INDEX getchar 208 getche 207 gets 209 gmtime 210 isalnum 212 isalpha 212 isatty 214 isdigit 212 islower 212 itoa 215 labs 216 Idexp 217 Idiv 218 localtime 219 log 221 log10 221 longjmp 222 ltoa 224 memcemp 225 mktime 227 modf 229 persist_check 230 persist_validate 230 pow 232 printf 33 putch 233 putchar 234 puts 236 qsort 237 rand 239 round 241 scanf 242 set_vector 246 setimp 244 sin 247 sinh 196 sqrt 248 srand 249 strcat 250 430 strchr 251 stremp 253 strcpy 255 strespn 256 strichr 251 stricmp 253
17. lt 5 f 1 0 printf e to 1 0f f n f exp f See Also logO log100 powQ 201 Library Functions FABS Synopsis include lt math h gt double fabs double f Description This routine returns the absolute value of its double argument Example include lt stdio h gt include lt math h gt void main void printf sf f n fabs 1 5 fabs 1 5 See Also abs labs 202 Library Functions FMOD Synopsis include lt math h gt double fmod double x double y Description The function fmod returns the remainder of x y as a floating point quantity Example include lt math h gt void main void double rem x x 12 34 rem fmod x 2 1 Return Value The floating point remainder of x y 203 Library Functions FLOOR Synopsis include lt math h gt double floor double f Description This routine returns the largest whole number not greater than f Example include lt stdio h gt include lt math h gt void main void printf Sf n floor 1 5 printf Sf n floor 1 5 204 Library Functions FREXP Synopsis include lt math h gt double frexp double f int p Description The frexp function breaks a floating point number into a normalized fraction and an integral power of 2 The integer is stored into the int object pointed to by p Its return value x is in the interval 0 5 1
18. one one in ROM produces warning const char ccp two two in ROM correct Defining and initializing a non const array i e not a pointer definition with a string for example char ca two two different to the above produces an array in data space which is initialised at startup with the string two copied from program space whereas a constant string used in other contexts represents an unnamed const qualified array accessed directly in program space HI TECH C will use the same storage location and label for strings that have identical character sequences except where the strings are used to initialise an array residing in the data space as shown in the last statement in the previous example Two adjacent string constants i e two strings separated only by white space are concatenated by the compiler Thus const char cp hello world assigned the pointer with the string hello world 3 3 2 Bit Data Types and Variables HI TECH C PRO for the PIC32 MCU Familysupports bit integral types which can hold the values 0 or 1 Single bit variables may be declared using the keyword bit bit objects declared within a function for example 69 Supported Data Types and Variables C Language Features static bit init_flag will be allocated in the bit addressable psect rbit and will be visible only in that function When the following declaration is used outside any function bit init_flag
19. returns the hyperbolic tangent value 196 Library Functions CPUTS Synopsis include lt conio h gt void cputs const char s Description The cputs function writes its argument string to the console outputting carriage returns before each newline in the string It calls putch repeatedly On a hosted system cputs differs from puts in that it writes to the console directly rather than using file I O In an embedded system cputs and puts are equivalent Example include lt conio h gt include lt string h gt char buffer 80 void main void for cgets buffer if strcmp buffer exit 0 break cputs Type exit to finish n See Also cputs puts putch 197 Library Functions CTIME Synopsis include lt time h gt char ctime time_t t Description The ctime function converts the time in seconds pointed to by its argument to a string of the same form as described for asctime Thus the example program prints the current time and date Example include lt stdio h gt include lt time h gt void main void time_t clock time amp clock printf Ss ctime amp clock See Also gmtime localtime asctime time Return Value A pointer to the string Note The example will require the user to provide the time routine as one cannot be supplied with the compiler See time for more detail 198
20. ride this option for that function See 3 3 10 5 2 6 33 LANG language Specify the Language for Messages This option allows the compiler to be configured to produce error warning and some advisory mes sages in languages other than English English is the default language and some messages are only ever printed in English regardless of the language specified with this option Table 2 10 shows those langauges currently supported See Section 2 5 for full details of the messaging system employed by PICC32 54 PICC32 Command line Driver PICC32 Driver Option Descriptions 2 6 34 MEMMAP file Display Memory Map This option will display a memory map for the specified map file This option is seldom required but would be useful if the linker is being driven explicitly i e instead of in the normal way through the driver This command would display the memory summary which is normally produced at the end of compilation by the driver 2 6 35 MSGDISABLE messagelist Disable Warning Messages This option allows warning or advisory messages to be disabled during compilation of all modules within the project and during all stages of compilation Warning mesasges can also be disabled using pragma directives For full information on the compiler s messaging system see Section 2 5 The messagelist is a comma separated list of warning numbers that are to be disabled If the number of an error is specified it will be ignored b
21. 723 function definitions nested too deep Code Generator This error is unlikely to happen with C code since C cannot have nested functions Contact HI TECH Support with details 724 bad op in revlog Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 726 bad op in uconval Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 727 bad op in bconfloat Code Generator This is an internal code generator error Contact HI TECH technical support with details 369 Error and Warning Messages 728 bad op in confloat Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 729 bad op in conval Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 730 bad op Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 731 expression error with reserved word Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 732 initialization of bit types is illegal Code Generator Variables of type bit cannot be initialised e g bit bl 1 oops bl must be assigned after its definition 733 bad string in pragma psect Code Generator The c
22. Addition of 32 bit values from initial value Fletcher s checksum 8 bit Fletcher s checksum 16 bit 5 14 1 6 FILL The FILL option is used for filling unused memory locations with a known value The usage of this option is FILL Code Start End data where e Code is the opcode that will be programmed to unused locations in memory Multi byte codes should be entered in little endian order e Start and End specify the address range that this fill will apply to For example FILL 3412 0 1FFF data will program opcode 1234h in all unused addresses from program memory address 0 to 1FFFh Note the endianism FILL accepts whole bytes of hexadecimal data from 1 to 8 bytes in length Adding the data flag to this option is not required If the data flag has been specified hexmate will only perform ROM filling to records that actually contain data This means that these records will be padded out to the default data record length or the width specified in the FORMAT option Records will also begin on addresses which are multiples of the data record length used The default data record length is 16 bytes This facility is particularly useful or is a requirement for some bootloaders that expect that all data records will be of a particular length and address alignment 170 Linker and Utilities Hexmate 5 14 1 7 FIND This option is used to detect and log occurrences of an opcode or partial code sequence Th
23. K Prevent overlaying function parameter and auto areas L Preserve relocation items in obj file IM Preserve segment relocation items in obj file Sort symbol table in map file by address order Nc Sort symbol table in map file by class address order Ns Sort symbol table in map file by space address order Mmapfile Generate a link map in the named file Oout file Specify name of output file Pspec Specify psect addresses and ordering Qprocessor Specify the processor type for cosmetic reasons only S Inhibit listing of symbols in symbol file Sclass limit bound Specify address limit and start boundary for a class of psects Usymbol Pre enter symbol in table as undefined Vavmap Use file avmap to generate an Avocet format symbol file Wwarnlev Set warning level 9 to 9 Wwidth Set map file width gt 10 X Remove any local symbols from the symbol file Z Remove trivial local symbols from the symbol file 5 7 1 Numbers in linker options Several linker options require memory addresses or sizes to be specified The syntax for all these is similar By default the number will be interpreted as a decimal value To force interpretation as a hex number a trailing H should be added e g 765FH will be treated as a hex number 140 Linker and Utilities Operation 5 7 2 Aclass low high Normally psects are linked according to the information given to a P option see below but some times it is desired to have
24. The absolute value of d is d n a abs a See Also labs fabsQ Return Value The absolute value of j 179 Library Functions ACOS Synopsis include lt math h gt double acos double f Description The acos function implements the inverse of cos i e it is passed a value in the range 1 to 1 and returns an angle in radians whose cosine is equal to that value Example include lt math h gt include lt stdio h gt Print acos values for 1 to 1 in degrees void main void float E sa for i 1 0 i lt 1 0 1 0 1 a acos i 180 0 3 141592 printf acos bf Sf degrees n i a See Also sin cos tan asin atan atan2 Return Value An angle in radians in the range 0 to 7 180 Library Functions ASCTIME Synopsis include lt time h gt char asctime struct tm t Description The asctime function takes the time broken down into the struct tm structure pointed to by its argument and returns a 26 character string describing the current date and time in the format Sun Sep 16 01 03 52 1973 n 0 Note the newline at the end of the string The width of each field in the string is fixed The example gets the current time converts it to a struct tm pointer with localtime it then converts this to ASCII and prints it The time function will need to be provided by the user see time for details Example include lt
25. The assembler associates no significance to the name of a psect and the linker is also not aware of which are compiler generated or user defined psects Unless defined as abs absolute psects are relocatable The following is an example showing some executable instructions being placed in the text 32 psect and some data being placed in the bss psect PSECT text32 class KSEGO_PFM adjust jal clear_fred increment lbu a3 _fred gptr gp addiu a3 a3 1 PSECT bss fred DS 1 PSECT text32 class KSEGO_PFM clear_fred sb zero _fred __gptr gp 120 Macro Assembler HI TECH C Assembly Language Note that even though the two blocks of code in the text 32 psect are separated by a block in the bss psect the two text 32 psect blocks will be contiguous when loaded by the linker In other words the addiu a3 a3 1 instruction will be followed by the clrf instruction in the final ouptut The actual location in memory of the text 32 and bss psects will be determined by the linker Code or data that is not explicitly placed into a psect will become part of the default unnamed psect 4 3 10 Assembler Directives Assembler directives or pseudo ops are used in a similar way to instruction mnemonicss but either do not generate code or generate non executable code i e data bytes The directives are listed in Table 4 7 and are detailed below 4 3 10 1 GLOBAL GLOBAL declares a list of symbols which if defined within the current module
26. but not recom mended 240 too many initializers Parser There are too many initializers for this object Check the number of initializers against the object definition array or structure e g three elements but four initializers int ivals 3 2 4 6 8 241 initialization syntax Parser The initialisation of this object is syntactically incorrect Check for the correct placement and num ber of braces and commas e g int iarray 10 a b c oops one two many s 242 illegal type for switch expression Parser A switch operation must have an expression that is either an integral type or an enumerated value e g double d switch d oops this must be integral case 1 0 d 0 311 Error and Warning Messages 243 inappropriate break continue Parser A break or cont inue statement has been found that is not enclosed in an appropriate control struc ture A continue can only be used inside a while for or do while loop while break can only be used inside those loops or a switch statement e g switch input case 0 if output 0 input Oxff oops this shouldn t be here and closed the switch break this should be inside the switch 244 default case redefined Parser There is only allowed to be one default label in a switch statement You have more than one e g switch a default if this is the default case
27. defined for use with the function These data types will be defined in the header file named under Synopsis See also any allied functions Return value the type and nature of the return value of the function if any Information on error returns is also included Only those categories which are relevant to each function are used 177 Library Functions _ CONFIG Synopsis include lt htc h gt _ CONFIG n data Description This macro is used to program the configuration fuses that set the device into various modes of operation The macro accepts a number corresponding to the configuration register 1t is to program then the value it is to update it with Macros have been defined to give a more readable name to the configuration register also masks have been created to describe each programmable attribute available on each device These attribute masks can be found tabulated in this manual in the Configuration Attributes section Multiple attributes can be selected by ANDing them together Example include lt htc h gt __CONFIG DEVCFGO GCP_OFF BWP_OFF ICS_PGx1 __CONFIG DEVCFG1 FWDTEN_ON amp WDTPS 0 void main void 178 Library Functions ABS Synopsis include lt stdlib h gt int abs int j Description The abs function returns the absolute value of j Example include lt stdio h gt include lt stdlib h gt void main void int a 5 printf
28. extern int calc int int int calc int a long int b hmmm which is right error flagged here return sin b a 253 argument list conflicts with prototype Parser The argument list in a function definition is not the same as a previous prototype for that function Check that the number and types of the arguments are all the same extern int calc int this is supposedly calc s prototype int calc int a int b hmmm which is right error flagged here return a b 314 Error and Warning Messages 254 undefined Parser This is an internal compiler error Contact HI TECH Software technical support with details 255 not a member of the struct union Parser This identifier is not a member of the structure or union type with which it used here e g struct int a b C data if data d oops there is no member d in this structure return 256 too much indirection Parser A pointer declaration may only have 16 levels of indirection 257 only register storage class allowed Parser The only storage class allowed for a function parameter is register e g void process static int input 258 duplicate qualifier Parser There are two occurrences of the same qualifier in this type specification This can occur either directly or through the use of a typedef Remove the redundant qualifier For example typedef volatile int vint oop
29. gt Spaces should not be included and the closing quote or bracket must be present There should be nothing else on the line other than comments e g include stdio h oops should be include lt stdio h gt 110 too many file arguments usage cpp input output Preprocessor CPP should be invoked with at most two file arguments Contact HI TECH Support if the preproces sor is being executed by a compiler driver 111 redefining preprocessor macro Preprocessor The macro specified is being redefined to something different to the original definition If you want to deliberately redefine a macro use undef first to remove the original definition e g define ONE 1 elsewhere Is this correct It will overwrite the first definition define ONE one 112 define syntax error Preprocessor A macro definition has a syntax error This could be due to a macro or formal parameter name that does not start with a letter or a missing closing parenthesis e g define FOO a 2b bar a 2b 2b is not to be 290 Error and Warning Messages 113 unterminated string in preprocessor macro body Preprocessor Assembler A macro definition contains a string that lacks a closing quote 114 illegal undef argument Preprocessor The argument to undef must be a valid name It must start with a letter e g tundef 6YYY this isn t a valid symbol name 115 recursive preprocessor
30. include lt stdlib h gt int uldiv unsigned long num Description unsigned long demon The uldiv function calculate the quotient and remainder of the division of number and denon storing the results into a uldiv_t structure which is returned Example include lt stdlib h gt void main void uldiv_t result unsigned long num 1234 result uldiv num den See Also IdivO udiv divO Return Value den 7 Returns the the quotient and remainder as a uldiv_t structure 280 Library Functions UNGETCH Synopsis include lt conio h gt void ungetch char c Description The ungetch function will push back the character e onto the console stream such that a subse quent getch operation will return the character At most one level of push back will be allowed See Also getch getche 281 Library Functions UTOA Synopsis include lt stdlib h gt char utoa char buf unsigned val int base Description The function itoa converts the unsigned contents of val into a string which is stored into buf The conversion is performed according to the radix specified in base buf is assumed to reference a buffer which has sufficent space allocated to it Example include lt stdlib h gt include lt stdio h gt void main void char buf 10 utoi buf 1234 16 printf The buffer holds s n buf See Also strtol itoa Itoa ultoa Return Value
31. lt 15 where var must be an unsigned int Rotates can be either left or right and of any number of bits Note that a rotate left of 1 bit is equalivent to a rotate right of 7 bits when dealing with byte wide variables or a rotate right of 15 bits when dealing with 2 byte quantities 3 2 Processor related Features HI TECH C PRO for the PIC32 MCU Family has many features which relate directly to the PIC32 family of processors These are detailed in the following sections 3 2 1 Processor Support HI TECH C PRO for the PIC32 MCU Family supports the full range of Microchip PIC 32 proces sors Additional code compatible processors may be added by editing the pic32 ini file in the DAT directory User defined processors should be placed at the end of the file The header of the file explains how to specify a processor Newly added processors will be available the next time you compile by selecting the name of the new processor on the command line in the usual way 3 2 2 Configuration Fuses The PIC32 processor s have several locations which contain the configuration bits or fuses These bits may be set using the configuration macro The macro has the form _ CONFIG n x there are two leading underscore characters where n is the configuration register number and x is the value that is to be the configuration word The macro will be defined if lt htc h gt is included so be sure to include that into each module that uses this macro Th
32. nvrram psect 76 object code version number 144 object files 42 absolute 144 relocatable 137 specifying name of 112 suppressing local symbols 112 symbol only 142 OBJTOHEX 158 command line arguments 158 objtohex application 23 operators assembly 118 Optimizations assembler 56 code generator 56 debugging 56 global 56 optimizations assembler see assembler optimizer optimizing assembly code 111 options assembler 110 ORG directive 124 output specifying name of 47 output directory 56 INDEX INDEX output file 47 output file formats 144 American Automation HEX 56 Binary 56 Bytecraft COD 56 COFF 56 ELF 56 Intel HEX 56 library 56 Microchip COFF 56 Motorola S19 HEX 56 specifying 56 158 Tektronic 56 UBROF 56 output files 56 L obj 23 names of 21 overlaid memory areas 143 overlaid psects 124 ovrld PSECT flag 124 p code files 20 PAGE assembler control 135 parameter passing 81 passing parameters to assembly 89 persist_check function 230 persist_validate function 230 persistent keyword 76 persistent qualifier 31 76 persistent variables 86 PIC32 MCU assembly language 113 PICC18 predefined macros 97 PICC32 see driver PICC32 supported data types 67 PICC32 options SUMMARY type 105 C 104 S 104 PICC32 output formats American Automation Hex 35 Binary 35 Intel Hex 35 Motorola Hex 35 Tektronix Hex 35 pointer qualifiers 78 pointers 78
33. printf s 44 should be printf f 44 0 330 pointer to argument required in printf style format string Parser A pointer argument is required for this format specifier Check the number and order of format specifiers and corresponding arguments 331 too few arguments for printf style format string Parser There are too few arguments for this format string This would result in a garbage value being printed or converted at run time e g printf sd 2d low oops where is the other value to print 332 interrupt_level should be 0 to 7 Parser The pragma interrupt_level must have an argument from 0 to 7 e g pragma interrupt_level oops what is the level void interrupt isr void isr code goes here 333 unrecognized qualifier name after strings Parser The pragma strings was passed a qualifier that was not identified e g oops should that be pragma strings const pragma strings cinst 334 unrecognized qualifier name after printf_check Parser The pragma print f_check was passed a qualifier that could not be identified e g oops should that be const not cinst pragma printf_check printf cinst 328 Error and Warning Messages 335 unknown pragma Parser An unknown pragma directive was encountered e g pragma rugsused w I think you meant regsused 336 string concatenation across lines Parser St
34. s driver 881 setup succeeded Driver The compiler has been successfully setup using the setup driver option 883 setup failed Driver The compiler was not successfully setup using the setup driver option Ensure that the directory argument to this option is spelt correctly is syntactically correct for your host operating system and it exists 387 Error and Warning Messages 884 please ensure you have write permissions to the configuration file Driver The compiler was not successfully setup using the setup driver option because the driver was unable to access the XML configuration file Ensure that you have write permission to this file The driver will search the following configuration files in order e the file specified by the environment variable HTC_XML e the file etc htsoft xml if the directory etc is writable and there is no htsoft xml file in your home directory e the file htsoft xml file in your home directory Tf none of the files can be located then the above error will occur 889 this compiler has expired Driver The demo period for this compiler has concluded 890 contact HI TECH Software to purchase and re activate this compiler Driver The evaluation period of this demo installation of the compiler has expired You will need to pur chase the compiler to re activate it If however you sincerely believe the evaluation period has ended prematurely please contact HI TECH
35. too few function arguments Parser This function requires more arguments than are provided in this call e g void add int a int b add 5 this call needs more arguments 188 constant expression required Parser In this context an expression is required that can be evaluated to a constant at compile time e g int a switch input case a oops can t use variable as part of a case label input 189 illegal type for array dimension Parser An array dimension must be either an integral type or an enumerated value int array 12 5 oops twelve and a half elements eh 302 Error and Warning Messages 190 illegal type for index expression Parser An index expression must be either integral or an enumerated value e g int i array 10 i array 3 5 oops exactly which element do you mean 191 cast type must be scalar or void Parser A typecast an abstract type declarator enclosed in parentheses must denote a type which is either scalar i e not an array or a structure or the type void e g lip long input oops maybe lip long input 192 undefined identifier Parser This symbol has been used in the program but has not been defined or declared Check for spelling errors if you think it has been defined 193 nota variable identifier Parser This identifier is not a variable it may be some other kind of object e g
36. true For example the following statement asserts that the pointer tp is not equal to NULL assert tp If at run time the expression evaluates to false the program will abort with a message identifying the source file and line number of the assertion and the expression used as an argument to it A fuller discussion of the uses of assert is impossible in limited space but it is closely linked to methods of proving program correctness Example void ptrfunc struct xyz tp assert tp 0 Note When required for ROM based systems the underlying routine _fassert will need to be imple mented by the user 184 Library Functions ATAN Synopsis include lt math h gt double atan double x Description This function returns the arc tangent of its argument i e it returns an angle e in the range 7 Example include lt stdio h gt include lt math h gt void main void printf Sf n atan 1 5 See Also sin cos tan asin acos atan2 Return Value The arc tangent of its argument 185 Library Functions ATAN2 Synopsis include lt math h gt double atan2 double x double x Description This function returns the arc tangent of y x Example include lt stdio h gt include lt math h gt void main void printf Sf n atan2 10 0 10 0 See Also sin cos tan asin acos atan Return Value The arc tangent
37. void main void char buf 80 printf Type a line if gets buf puts buf See Also fgets freopen puts Return Value It returns its argument or NULL on end of file 209 Library Functions GMTIME Synopsis include lt time h gt struct tm gmtime time_t t Description This function converts the time pointed to by t which is in seconds since 00 00 00 on Jan 1 1970 into a broken down time stored in a structure as defined in time h The structure is defined in the Data Types section Example include lt stdio h gt include lt time h gt void main void time_t clock struct tm tp time amp clock tp gmtime amp clock printf It s d in London n tp gt tm_year 1900 See Also ctime asctime time localtime 210 Library Functions Return Value Returns a structure of type tm Note The example will require the user to provide the time routine as one cannot be supplied with the compiler See time for more detail 211 Library Functions ISALNUM ISALPHA ISDIGIT ISLOWER et al Synopsis H H He H He H H H H H H H inc isalnum isalpha isascii iscntrl isdigit islower isprint isgraph ispunct isspace isupper isxdigit CB cE GR CR rt ret Ap et GE ack ck et Description nar nar nar nar nar nar nar nar nar nar nar nar lude lt ctype h gt 4 0 OO GQ
38. y a Ist A ASMLI ST ee ee assembler PA Obj z y HLINK 2 2 The Compilation Sequence PICC32 will check each file argument and perform appropriate actions on each file The entire compilation sequence can be thought of as the initial sequence up to the link stage and the final sequence which takes in the link step and any post link steps required Graphically the compilation steps up to the link stage are illustrated in Figure 2 1 This diagram shows all possible input files along the top intermediate and transitional files along the right side and useful compiler output files along the left Generated files are shown along with the options that are used to generate and preserve these All the files shown on the right can be generated and fed to the compiler in a subsequent compile step those on the left are used for debug purposes and cannot be used as an input to any subsequent compilation The individual compiler applications are shown as boxes The C preprocessor CPP and parser P1 have been grouped together for clarity The thin multi arrowed lines indicate the flow of multiple files one for each file being pro cessed by the revel ant application The thick single arrowed lines indicate a single file for the project being compiled Thus for example when using the PASS1 driver option the parser produces one pl file for each C source file that is being compiled as part of the project but the c
39. 0 or zero and f equals x times 2 raised to the power stored in p If f is zero both parts of the result are zero Example include lt math h gt include lt stdio h gt void main void double f int i f frexp 23456 34 81 printf 23456 34 f 2 d n f 1 See Also IdexpQ 205 Library Functions FTOA Synopsis include lt stdlib h gt char ftoa float f int status Description The function ftoa converts the contents of f into a string which is stored into a buffer which is then return Example include lt stdlib h gt include lt stdio h gt void main void char buf float input 12 34 int status buf ftoa input amp status printf The buffer holds s n buf See Also strtol itoa utoa ultoa Return Value This routine returns a reference to the buffer into which the result is written 206 Library Functions GETCH GETCHE Synopsis include lt conio h gt char getch void char getche void Description The getch function reads a single character from the console keyboard and returns it without echo ing The getche function is similar but does echo the character typed In an embedded system the source of characters is defined by the particular routines supplied By default the library contains a version of getch that will interface to the Lucifer Debugger The user should supply an appropriate routine if ano
40. 055h lt lt orshl Shift left DB inp gt gt 8 gt gt orshr Shift right ovlw inp shr 2 rol Rotate left DB inp rol 1 ror Rotate right DB inp ror 1 float24 24 bit version of real operand DW float24 3 3 nul Tests if macro argument is null 119 HI TECH C Assembly Language Macro Assembler apply The operators listed may all be freely combined in both constant and relocatable expressions The HI TECH linker permits relocation of complex expressions so the results of expressions involving relocatable identifiers may not be resolved until link time 4 3 9 Program Sections Program sections or psects are simply a section of code or data They are a way of grouping together parts of a program via the psect s name even though the source code may not be physically adjacent in the source file or even where spread over several source files The concept of a program section is not a HI TECH only feature Often referred to as blocks or segments in other compilers these grouping of code and data have long used the names text bss and data A psect is identified by a name and has several attributes The PSECT assembler directive is used to define a psect It takes as arguments a name and an optional comma separated list of flags See Section 4 3 10 3 for full information on psect definitions Chapter 5 has more information on the operation of the linker and on optins that can be used to control psect placement in memory
41. 10 1 Persistent Type Qualifier By default any C variables that are not explicitly initialised are cleared to zero on startup This is consistent with the definition of the C language However there are occasions where it is desired for some data to be preserved across resets or even power cycles on off on The persistent type qualifier is used to qualify variables that should not be cleared on startup In addition any persistent variables will be stored in a different area of memory to other variables Persistent objects are placed within one of the non volatile psects If the persistent object is also qualified near it placed in the nvrram psect Persistent bit objects are placed within the nvbit psect All other persistent objects are placed in the nvram psect 76 C Language Features Supported Data Types and Variables 3 3 10 2 cp0 Type Qualifier The cp0 type qualifier is used to facilitate access within C programs to the registers of the system coprocessor 0 CPO Any 4 byte unsigned integer variable may be so qualified These variables must also be made absolute and assigned a magic number which encodes the register and the selection number These magic numbers have been defined in lt pic32 h gt as well as variable definitions for each of the CPO registers 3 3 10 3 sfr Type Qualifier Variables qualifed as sfr and given an absolute address that of the corresponding SFR will instruct the compiler to generate code which takes
42. 1192 licensed for evaluation purposes only Driver Indicates that this compiler has been activated with an evaluation licence 405 Error and Warning Messages 1193 this licence will expire on Driver The compiler has been installed as a time limited trial This trial will end on the date specified 1195 invalid syntax for option Driver A command line option that accepts additional parameters was given inappropriate data or insuffi cient data For example an option may expect two parameters with both being integers Passing a string as one of these parameters or supplying only one parameter could result in this error 1198 too many specifications maximum Hexmate This option has been specified too many times If possible try performing these operations over several command lines 1199 compiler has not been activated Driver The trial period for this compiler has expired The compiler is now inoperable until activated with a valid serial number Contact HI TECH Software to purchase this software and obtain a serial number 1200 Found 0 IXh at address h Hexmate The code sequence specified in a FIND option has been found at this address 1201 all FIND REPLACE code specifications must be of equal width Hexmate All find replace and mask attributes in this option must be of the same byte width Check the parameters supplied to this option For example finding 1234h 2 bytes masked with FFh 1 b
43. 20000 8000 2FFO 50 32MX340F128L 20000 8000 2FFO 50 32MX340F256H 40000 8000 2FFO 50 32MX340F5 12H 80000 8000 2FFO 50 32MX360F256L 40000 8000 2FFO 50 32MX360F512L 80000 8000 2FFO 50 32MX420F032H 8000 2000 2FFO 28 32MX440F128H 20000 8000 2FFO 50 32MX440F128L 20000 8000 2FFO 50 32MX440F256H 40000 8000 2FFO 50 32MX440F5 12H 80000 8000 2FFO 50 32MX460F256L 40000 8000 2FFO 50 32MX460F512L 80000 8000 2FFO 50 32MXGENERIC 80000 8000 2FFO 50 415 Chip Information 416 Appendix D Configuration Attributes The following tables present the various configuration attributes available for the various config words in PIC32 devices These attributes are usable with the __CONFIG n x macro GCP_ON Code Protection Enable GCP_OFF BWP_ON Boot Flash Write protect BWP_OFF PWP_BLKS k Program Flash Write protect bits creates the config setting for the program write protection of the first k 4k blocks beginning at OxBD000000 k is an integer between 0 and 128 PWP_OFF ICESEL_PGx2 ICE ICD Communication Channel Select ICESEL_PGx1 BKBUG_ON Background Debugger Enable BKBUG_OFF Configuration Word 0 DEVCFG0 417 Configuration Attributes FWDTEN_ON WDT Enable FWDTEN_OFF WINDIS_ON Windowed WDT Disable WINDIS_OFF macro The Macro WDTPS s creates the __WDTPS s config setting for the WDT postscale bits where s gives a postscale of 1 2 s s is an integer between 0 and 20
44. 4 1 The pragma jis and nojis Directives If your code includes strings with two byte characters in the JIS encoding for Japanese and other na tional characters the pragma jis directive will enable proper handling of these characters specif ically not interpreting a backslash character when it appears as the second half of a two byte character The nojis directive disables this special handling JIS character handling is disabled by default 3 11 4 2 The pragma printf_check Directive Certain library functions accept a format string followed by a variable number of arguments in the manner of printf Although the format string is interpreted at runtime it can be compile time 100 C Language Features Preprocessing checked for consistency with the remaining arguments This directive enables this checking for the named function e g the system header file lt stdio h gt includes the directive pragma printf_check printf const to enable this checking for printf You may also use this for any user defined function that accepts print f style format strings The qualifier following the function name is to allow automatic conversion of pointers in variable argu ment lists The above example would cast any pointers to strings in RAM to be pointers of the type const char Note that the warning level must be set to 1 or below for this option to have any visible effect See Section 2 6 57 3 11 4 3 The pragma regsused Direct
45. 4 3 HI TECH C Assembly Language The source language accepted by the macro assembler ASPIC32_ is described below All opcode mnemonics and operand syntax are strictly PIC32 assembly language Additional mnemonics and assembler directives are documented in this section 4 3 1 Pre defined Macros The PIC32 assembler features a number of convenient in built macro instructions for both MIPS32r2 and MIPS 16e instruction set architectures The following sections describe these in more detail Note that these descriptions use the same notation used in the official MIPS documentation 4 3 1 1 MIPS32r2 In built Macro Instructions LI rt immediate Loads the immediate operand into the register rt using various combina tions of LUI ORI and ADDIU instructions where appropriate LI rd rt immediate Loads the immediate operand into the register rd using various combi nations of LUI ORI and ADDIU instructions where appropriate If two instructions are required then rt is used as a temporary register to store an intermediate result MOVE rd rs AsynonymofOR rd rs zero NEG rd rt A synonym of SUB rd zero rt NEGU rd rt Asynonym of SUBU rd zero rt NOT rd rt AsynonymofNOR rd zero rt 4 3 1 2 MIPS16E In built Macro Instructions ADDIUPC rx immediate A synonym of ADDIU rx pc immediate LI32 rx immediate Loads the 32 bit immediate operand into the register rx Literal con stant immediate operands are loaded into the register using vari
46. 8 in the map file The length given in the map file for bit psects is in units of bits not bytes All addresses specified for bit objects are also bit addresses The bit psects are cleared on startup but are not initialised To create a bit object which has a non zero initial value explicitly initialise it at the beginning of your code If the PICC32 flag STRICT is used the bit keyword becomes unavailable 3 3 3 Using Bit Addressable Registers The bit variable facility may be combined with absolute variable declarations see Section 3 4 2 to access bits at specific addresses Absolute bit objects are numbered from 0 the least significant bit 70 C Language Features Supported Data Types and Variables of the first byte up Therefore bit number 3 the fourth bit in the byte since numbering starts with 0 in byte number 5 is actually absolute bit number 43 that is 8bits byte 5 bytes 3 bits For example to access the software reset detection flag bit in the RCON register declare RCON to be a C object at absolute address BF80F600h then declare a bit variable at absolute bit address 2i static unsigned long RCON 0xBF80F600 static near bit SWR unsigned amp RCON 8 6 Note that all standard registers and bits within these registers are defined in the header files provided The only header file you need to include to have access to the PIC32 registers is lt htc h gt at compile time this will include the appropriate he
47. A eS ERE RS aA e api 265 SIRSPN cora owe MEME EAN Rw eee a ee ee aS 266 PERO UR ck he a OR a A Rk A Be a Bae Gi Boe See aces He esis 267 STRIOD 25 044 40484 506400 be BEE Ad Eee dee eRe ee eee 268 SIR Sek eS ee OA RES RR ee we ee ee oe ae ed 270 CONTENTS CONTENTS STRTOK TAN pron ahs me hod BR a ha lB TIM sec ho wae oa Rae ad ee eB TRUNC UTOA AAA APOL iia ee C Chip Information D Configuration Attributes Index 14 List of Tables 21 22 23 2 4 25 2 6 ub 2 8 2 9 2 10 2 11 2 12 2 14 3 10 3 11 4 1 4 2 PICC 32 put Mety pes a r Son ce Bae Raw ee bees e dt Ae eS BSS Default configuration settings 2 2 2 a Support languages sce ee A al a ee ae oa Messaging environment variables 2 2 2 0 2 2 o eee eee Messaging placeholders a ce roses ross es Supported IDES aun ra Ge eR a AGS Baas Bee interrupts sub options affecting the type of interrupt vectors interrupts sub options affecting the location of the vector table interrupts sub options affecting the number of vectors to service interrupts Supported languages cocos to A e E eS Optimization ODIONS 3 2 Gad ee OR ARA ee eS Output mle formate s sl he Soe ee AE ES Qs Re a BIR Memory Summary Suboptions lt s 5 5 0 6055255 208 eb a np Base datatypes cun Se RE ER Se Ee SA ee e aS Radik formals ica Soe Boe a aoe Se ome dee Gee Ee ee Se Floating point formats Floating point format example
48. A global or static variable can be located at an absolute address by following its declaration with the construct address for example volatile unsigned char Portvar 0x06 will declare a variable called Portvar located at 06h The compiler will reserve storage for this object via the assembler DABS directive and will equate the variable to that address The compiler generated assembler will include a line of the form _Portvar EQU 06h This construct is primarily intended for equating the address of a C identifier with a microprocessor special function register but can be used to place user defined variables at an absolute address The compiler and linker do not make any checks for overlap of absolute variables with other absolute variables Defining absolute objects can fragment memory and may make it impossible for the linker to position other objects Avoid absolute objects if at all possible If absolute objects must be defined try to place them at one end of a memory bank or space 3 4 3 Objects in Program Space Const objects are usually placed in program space On PIC32 devices the program space is 32 bit wide the compiler stores one character per byte location and values are read using the table read instructions All const qualified data objects and string literals are placed in either the const or farconst psect depending on the amount of const data defined in the program The appropriate const psect is placed at an addres
49. ABC is non zero the first jmp instruction will be assembled but not the second or third If ABC is zero and DEF is non zero the second jmp will be assembled but the first and third will not If both ABC and DEF are zero the third jmp will be assembled Conditional assembly blocks may be nested 4 3 10 15 MACRO and ENDM These directives provide for the definition of macros The MACRO directive should be preceded by the macro name and optionally followed by a comma separated list of formal parameters When the macro is used the macro name should be used in the same manner as a machine opcode followed by a list of arguments to be substituted for the formal parameters For example macro storem jargs argl the NAME of the source variable arg2 the literal value to load descr Loads two registers with the value in the variable ldtwo MACRO argl arg2 movlw amp arg2 movwf amp arg1 ENDM When used this macro will expand to the 2 instructions in the body of the macro with the formal parameters substituted by the arguments Thus storem tempvar 2 expands to movlw 2 movwf tempvar A point to note in the above example the amp character is used to permit the concatenation of macro parameters with other text but is removed in the actual expansion A comment may be suppressed within the expansion of a macro thus saving space in the macro storage by opening the comment with a double semicolon 128 Macro Assembler H
50. IEEE 734 0 e Intesralmivisioni 29 he ehide e442 A a ds dt Preprocessor directives ra c ce be ke AREER ER BA ea ee Prapma directives o o e ceeace a ERAS ede eA A Valid register fames o os a e S ee A A SWHEN TYPES 4 o A A a eS Supported standard I O functions e ASPIC32 command line Options e MIPS32r2 Assembly Instruction Operand Variants o 15 LIST OF TABLES LIST OF TABLES 16 4 3 44 4 5 4 6 4 7 4 8 4 9 4 10 4 11 Sal Sel 3 2 3 9 5 4 a 5 6 5 7 5 8 39 3 10 Si CA MIPS16e Assembly Instruction Operand Variants 116 ASPICIZ statement formats s s ek ea kok eS Be a A ee 116 ASPIC32 numbers and bases osoo ee ee ew 117 ASPICIZ Operators e G96 lect oe gs a oe SE SS Ge a ws Eke 119 ASPICIZ assembler directives ee spero A 122 Pom Wags ota EA ge eee Ses eee SO E PARES os 123 psect isata subap s oder be GOR Pe RES eee we eS 125 PIC S2 assembler controls 5 5 ia eS Re SSS SSE a SAS eS 132 List control GpuOns lt slacks ek hw A Ae 4 eR ee G 134 Linker command line Options ss lt s s a ee ro 139 Linker command line options 2 2 2 2 0 2 20000000000 140 Librarian command line options 2000002200005 156 Librarian key letter Commands lt 4 races a e e Re ee i Se eS 156 OBJTOHEX command line options 2 2 ee ee 159 CREF command line Options eR eR RE es 161 CROMW
51. OQ Qi On 1 CO These macros defined in ctype h test the supplied character for membership in one of several over lapping groups of characters Note that all except isascii are defined for e if isascii c is true or if c EOF 212 isalnum c isalpha c isascii c iscntrl c isdigit c islower c isprint c isgraph c ispunct c isspace c isupper c isxdigit c c is in 0 9 or a z or A Z cis in A Z or a z cis a 7 bit ascii character c is a control character c is a decimal digit c is in a z c is a printing char c is a non space printable character c is not alphanumeric c is a space tab or newline cis in A Z c is in 0 9 or a f or A F Library Functions Example include lt ctype h gt include lt stdio h gt void main void char buf 80 int i gets buf i 0 while isalnum buf i itt buf i 0 printf s is the word n buf See Also toupper tolower toascii 213 Library Functions ISDIG Synopsis include lt ctype h gt int isdig int c Description The isdig function tests the input character c to see if is a decimal digit 0 9 and returns true is this is the case false otherwise Example include lt ctype h gt void main void char buf 1998a if isdig buf 0 printf valid type detected n See Also isdigit listed un isalnum Return Value Zero if the character is a de
52. PIC14 Microchip mid range PIC chips PIC16 Microchip high end 17Cxxx PIC chips PIC18 Microchip PIC18 chips PIC24 Microchip PIC24F and PIC24H chips PIC30 Microchip dsPIC30 and dsPIC33 chips 5 13 4 C This option will attempt to identify if the specified input files are one of the formats as shown in Table 5 6 If the file is recognised a confirmation of its type will be displayed 5 13 5 F When generating a COD file this option can be used to force all local symbols to be represented as global symbols The may be useful where an emulator cannot read local symbol information from the COD file 5 13 6 Okey This option specifies the format of the output file The key can be any of the types listed in Table 3 6 5 13 7 Ikey This option can be used to specify the default input file format The key can be any of the types listed in Table 5 6 5 13 8 L Use this option to show what file format types are supported A list similar to that given in Table 5 6 will be shown 164 Linker and Utilities Hexmate 5 13 9 E Use this option to tell CROMWELL to ignore any filename extensions that were given The default extension will be used instead 5 13 10 B In formats that support different endian types use this option to specify big endian byte ordering 5 13 11 M When generating COD files this option will remove the preceding underscore character from sym bols 5 13 12 V Turns on verbose mode
53. PSECT Declare or resume program section ORG Set location counter EQU Define symbol value SET Define or re define symbol value DB Define constant byte s DW Define constant word s DS Reserve storage DABS Define absolute storage IF Conditional assembly ELSIF Alternate conditional assembly ELSE Alternate conditional assembly ENDIF End conditional assembly FNADDR Inform the linker that a function may be indirectly called FNARG Inform the linker that evaluation of arguments for one function requires calling another FNBREAK Break call graph links FNCALL Inform the linker that one function calls another FNCONF Supply call graph configuration information for the linker FNINDIR Inform the linker that all functions with a particular signature may be indirectly called FNROOT Inform the linker that a function is the root of a call grpah FNSIZE Inform the linker of argument and local variable for a function MACRO Macro definition ENDM End macro definition LOCAL Define local tabs ALIGN Align output to the specified boundary PAGESEL Generate set reset instruction to set PCLATH for this page PROCESSOR Define the particular chip for which this file is to be assembled REPT Repeat a block of code n times IRP Repeat a block of code with a list IRPC Repeat a block of code with a character list SIGNAT Define function signature 122 Macro Assembler HI TECH C Assembly Language Table 4 8 PSECT flags
54. Parser This expression implies a conversion between incompatible types e g a conversion of a structure type into an integer e g struct LAYOUT layout int iy layout i int cannot be converted to struct Note that even if a structure only contains an int for example it cannot be assigned to an int variable and vice versa 183 function or function pointer required Parser Only a function or function pointer can be the subject of a function call e g ints ay bj Ud a b ctd b is not a function did you mean a b ctd 184 calling an interrupt function is illegal Parser A function qualified interrupt can t be called from other functions It can only be called by a hardware or software interrupt This is because an interrupt function has special function entry and exit code that is appropriate only for calling from an interrupt An interrupt function can call other non interrupt functions 185 function does not take arguments Parser Code Generator This function has no parameters but it is called here with one or more arguments e g 301 Error and Warning Messages int get_value void void main void int input input get_value 6 oops parameter should not be here 186 too many function arguments Parser This function does not accept as many arguments as there are here void add int a int b add 5 7 input call has too many arguments 187
55. The chipinfo file contains no data If you have not manually edited the chip info file contact HI TECH Support with details 383 Error and Warning Messages 834 page width must be gt 60 Assembler The listing page width must be at least 60 characters Any less will not allow a properly formatted listing to be produced e g LIST C 10 the page width will need to be wider than this 835 form length must be gt 15 Assembler The form length specified using the F length option must be at least 15 lines Setting this length to zero is allowed and turns off paging altogether The default value is zero pageless 836 no file arguments Assembler The assembler has been invoked without any file arguments It cannot assemble anything 839 relocation too complex Assembler The complex relocation in this expression is too big to be inserted into the object file 840 phase error Assembler The assembler has calculated a different value for a symbol on two different passes This is probably due to bizarre use of macros or conditional assembly 844 lexical error Assembler Optimiser An unrecognized character or token has been seen in the input 845 symbol defined more than once Assembler This symbol has been defined in more than one place The assembler will issue this error if a symbol is defined more than once in the same module e g _next move r0 55 move rl r0 _next oops choos
56. The page width suboption to the LIST assembler directive must specify a with of at least 49 862 symbol is not external Assembler A symbol has been declared as EXTRN but is also defined in the current module 385 Error and Warning Messages 864 argument to size psect flag must specify a positive constant Assembler The parameter to the PSECT assembler directive s size option must be a positive constant number e g PSECT text class CODE size 200 a negative size 865 psect flag size redefined Assembler The size flag to the PSECT assembler directive is different from a previous PSECT directive e g psect spdata class RAM size 400 elsewhere psect spdata class RAM size 500 867 psect flag reloc redefined Assembler The reloc flag to the PSECT assembler directive is different from a previous PSECT directive e g psect spdata class RAM reloc 4 elsewhere psect spdata class RAM reloc 8 868 argument to delta psect flag must specify a positive constant Assembler The parameter to the PSECT assembler directive s DELTA option must be a positive constant number e g PSECT text class CODE delta 2 negative delta value doesn t make sense 869 psect flag delta redefined Assembler The DELTA option of a psect has been redefined more than once in the same module 870 argument to pad psect flag must specify a positive constant Assembler The parameter to the PSECT assembler dir
57. This includes clearing the Count register and status bits and ini tialising the Cause and EBase registers It also includes any other initialisations performed by other RUNTIME sub options This behaviour is enabled by default 2 3 2 4 General Purpose Register Intialization RUNTIME gpr For the purpose of code generation some of the CPU general purpose registers are initialised with special values e g register 28 is used as a global data pointer and is initialised with an address in the middle of KSEGO DRM This behaviour is enabled by default 2 3 2 5 The Stack and Heap RUNTIME stack RUNTIME heap The allocation and size of the program stack and heap can be specified with the sub options stack and heap respectively Both reserve memory for the these regions and the stack sub option will initialise the stack pointer register 29 accordingly By default both options are enabled The default behaviour is that both the stack and the heap are reserved the same area of memory as indicated by the compiler generated psect heapstack The stack grows down from the top of this psect and the heap grows up from the bottom The heapstack psect is allocated the largest available space in RAM that is word aligned and divisible after all other data psects have been allocated Arguments can also be provided to each of these sub options that place restrictions on the size of the stack or heap Each argument is delimited by a colon Valid argume
58. This information is used to ensure the code generator takes into account requirement of the assembly code 3 10 4 1 Absolute Psects Some of the information that is extracted from the relocatable objects by the driver relates to absolute psects specifically psects defined using the abs and ovrld PSECT flags see Section 4 3 10 3 for more information These are psects have been rarely required in general coding but do allow for data to be collated over multiple modules in a specific order HI TECH C PRO for the PIC32 MCU Family is able to determine the address bounds of abso lute psects to enure that the output of C code does not consume specific resources required by the assembly code The code generator will ensure that any memory used by these psects are reserved and not used by C code The linker options are also adjusted by the driver to enure that this memory is not allocated 94 C Language Features Mixing C and Assembly Code TUTORIAL PROCESSING OF ABSOLUTE PSECTS An assembly code files defines a table that must be located at address 210h in the data space The assembly file contains PSECT lkuptbl class RAM space 1 abs ovlrd ORG 210h lookup ds 20h When the project is compiled this file is assembled and the resulting relocatable object file scanned for absolute psects As this psect is flagged as being abs and ovlra the bounds and space of the psect will be noted in this case a memory range from address 210h to 2
59. a checksum list read by OBJTOHEX The checksum list is read from standard input in response to an option 343 Error and Warning Messages 428 too many segment fixups Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 429 bad segment fixups Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 430 bad checksum specification Objtohex A checksum list supplied to OBJTOHEX is syntactically incorrect 431 bad argument to E Objtoexe This option requires an integer argument in either base 8 10 or 16 If you are invoking objtoexe directly then check this argument Otherwise this may be an internal compiler error and you should contact HI TECH Software technical support with details 432 usage objtohex ssymfile object file exe file Objtohex Improper usage of the command line tool objtohex If you are invoking objtohex directly then please refer to Section 5 11 for more details Otherwise this may be an internal compiler error and you should contact HI TECH Software technical support with details 434 too many symbols Linker There are too many symbols in the symbol table which has a limit of symbols Change some global symbols to local symbols to reduce the number of symbols 435 bad segment selector Linker The segment specification option G to the linker is invalid e g GA
60. address Long and unsigned long occupy 32 bits as this is the smallest long integer size allowed by the ANSI standard for C Variables may be declared using the signed long int and unsigned long int keyword se quences respectively to hold values of these types Where only long int is used in the declaration the type will be signed long When specifying this type the keyword int may be omitted Thus a variable declared as long will contain a signed long int and a variable declared as unsigned long will contain an unsigned long int 3 3 7 Floating Point Types and Variables Floating point is implemented using the IEEE 754 32 bit format The 32 bit format is used for all float and double values This format is described in Table 3 3 where e sign is the sign bit e The exponent is 8 bits which is stored as excess 127 i e an exponent of 0 is stored as 127 e mantissa is the mantissa which is to the right of the radix point There is an implied bit to the left of the radix point which is always except for a zero value where the implied bit is zero A zero value is indicated by a zero exponent The value of this number is 1 87 x 2 exponeni 127 x 1 mantissa Here are some examples of the IEEE 754 32 bit formats Note that the most significant bit of the mantissa column in Table 3 4 that is the bit to the left of the radix point is the implied bit which is assumed to be unless the exponent is zero in which case the float is zero
61. address These files have the extension sdb The base name will be the same as the base name of the module being compiled Thus the above command line would also generate symbols files with the names test sdb and init sdb 2 5 Compiler Messages All compiler applications including the command line driver PICC32 use textual messages to report feedback during the compilation process A centralized messaging system is used to produce the messages which allows a consistancy during all stages of the compilation process 2 5 1 Messaging Overview A message is referenced by a unique number which is passed to the alert system by the compiler application that needs to convey the information The message string corresponding to this number is obtained from Message Description Files MDF which are stored in the DAT directory of the compiler distribution When a message is requested by a compiler application its number is looked up in the MDF which corresponds to the currently selected language The language of messages can be altered as discussed in Section 2 5 2 Once found the alert system determines the message type that should be used to display the message There are several different message types which are described in Section 2 5 3 The default type is stored in the MDF however this can be overridden by the user as described in Section 2 5 3 The user is also able to set a threshold for warning message importance so that only those which th
62. allows the type of the output file s to be specified If no OUTPUT option is specified the output file s name will be derived from the first source or object file specified on the command line The available output file format are shown in Table 2 12 More than one output format may be specified by supplying a comma separated list of tags Those output file types which specify library formats stop the compilation process before the final stages of compilation are executed Hence 56 PICC32 Command line Driver PICC32 Driver Option Descriptions Table 2 12 Output file formats Type tag File format lib Library File lpp P code library intel Intel HEX tek Tektronic aahex American Automation symbolic HEX file mot Motorola S19 HEX file ubrof UBROF format bin Binary file cof Common Object File Format cod Bytecraft COD file format elf ELF DWARF file format specifying an output file format list containing e g 1ib or all will over ride the non library output types and only the library file will be created 2 6 43 PASS1 Compile to P code The PASS1 option is used to generate a p code intermediate files p1 file from the parser then stop compilation Such a file needs to be generated if creating a p code library file 2 6 44 PRE Produce Preprocessed Source Code The PRE option is used to generate preprocessed C source files with an extension pre This may be usefu
63. and Utilities addri addr2 wherel where2 t toffset All of addr1 addr2 wherel where2 and offset are hex numbers without the usual H suffix Such a specification says that the bytes at addr1 through to addr2 inclusive should be summed and the sum placed in the locations where1 through where2 inclusive For an 8 bit checksum these two addresses should be the same For a checksum stored low byte first where1 should be less than where2 and vice versa The offset is optional but if supplied the value offset will be used to initialise the checksum Otherwise it is initialised to zero For example 0005 1FFF 3 4 1FFF This will sum the bytes in 5 through 1FFFH inclusive then add 1FFFH to the sum The 16 bit checksum will be placed in locations 3 and 4 low byte in 3 The checksum is initialised with 1FFFH to provide protection against an all zero ROM or a ROM misplaced in memory A run time check of this checksum would add the last address of the ROM being checksummed into the checksum For the ROM in question this should be 1FFFH The initialization value may however be used in any desired fashion 5 12 Cref The cross reference list utility CREF is used to format raw cross reference information produced by the compiler or the assembler into a sorted listing A raw cross reference file is produced with the CR option to the compiler The assembler will generate a raw cross reference file with a C option most assemblers or by using a
64. are made public If the symbols are not defined in the current module it is a reference to symbols in external modules Example GLOBAL labl lab2 lab3 4 3 10 2 END END is optional but if present should be at the very end of the code defined in the module It will terminate the assembly process and not even blank lines should follow this directive If an expression is supplied as an argument that expression will be used to define the entry point address of the program Whether this is of any use will depend on the type of output debug file being generated and the target platform It is typically most useful for hosted systems where an application program may not be located at the reset vector For example if start_label is defined at the reset vector END start_label 4 3 10 3 PSECT The PSECT directive declares or resumes a program section It takes as arguments a name and optionally a comma separated list of flags The allowed flags are listed in Table 4 8 below Once a psect has been declared it may be resumed later by another PSECT directive however the flags need not be repeated 121 HI TECH C Assembly Language Macro Assembler Table 4 7 ASPIC32 assembler directives Directive Purpose GLOBAL Make symbols accessible to other modules or allow reference to other modules symbols END End assembly
65. arguments to printf following the format string represented by mes Thus the only valid format strings will not contain placeholders that print any arguments and a minimal version of printf will be generated and compiled If the above code was rewritten as void my_print const char mes double val printf mes val 34 PICC32 Command line Driver Debugging Information the compiler will detect that the argument being printed has double type thus the only valid placeholders would be those that print floating point types for example e f and Sg No aspect of this operation is user controllable other than by adjusting the calls to printf how ever the actual printf code used by a program can be observed If compiling a program using printf the driver will leave behind the pre processed version of doprnt c This module called doprnt pre in your working directory will show the C code that will actually be contained in the printf routine As this code has been pre procedssed indentation and comments will have been stripped out as part of the normal actions taken by the C pre processor 2 4 Debugging Information Several driver options and output files are related to allow devlopment tools such as HI TIDE or MPLAB to perform source level debugging of the output code These are described in the following sections 2 4 1 Output File Formats The compiler is able to directly produce a number of the output file fo
66. arguments which overlap between two functions This could occur with a call like void fnl void i fn3 7 fn2 3 fn2 9 Offending call as fn2 char fred return fred fn3 5 1 0 a fn3 char one char two char three return one two three 371 Error and Warning Messages where fn1 is calling n3 and two arguments are evaluated by calling fn2 which in turn calls n3 The program structure should be modified to prevent this type of call sequence 743 divide by zero Code Generator An expression involving a division by zero has been detected in your code 744 static object has zero size Code Generator A static object has been declared but has a size of zero 745 nodecount Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 746 object qualified const but not initialized Code Generator An object has been qualified as const but there is no initial value supplied at the definition As this object cannot be written by the C program this may imply the intial value was accidently omitted 747 unrecognized option to Z Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 748 variable may be used before set Code Generator This variable may be used before it has been assigned a value Since it is an auto variable this will result in it having a
67. be entered in little endian byte order 2 6 28 GETOPTION app file Get Command line Options This option is used to retrieve the command line options which are used for named compiler appli cation The options are then saved into the given file This option is not required for most projects 2 6 29 HELP lt option gt Display Help The HELP option displays information on the PICC32 compiler options To find out more about a particular option use the option s name as a parameter For example PICC32 help warn This will display more detailed information about the WARN option the available suboptions and which suboptions are enabled by default 2 6 30 IDE type Specify the IDE being used This option is used to automatically configure the compiler for use by the named Integrated Devel opment Environment IDE The supported IDE s are shown in Table 2 6 2 6 31 INTERRUPTS suboption lt suboption gt Specify the Interrupts Scheme This option will instruct the compiler to initialise the device and the vector table according to the desired scheme The interrupt scheme is specified using sub options to this driver option in a similar fashion to the runt ime option Sub options are divided into three groups which are as follows e sub options which affect the type of interrupt vectors see Table 2 7 52 PICC32 Command line Driver PICC32 Driver Option Descriptions SUB OPTION MEANING rom defau
68. bind correctly 282 functions can t return arrays Parser A function can return only a scalar simple type or a structure It cannot return an array 283 dimension required Parser Only the most significant i e the first dimension in a multi dimension array may not be assigned a value All succeeding dimensions must be present as a constant expression e g This should be e g int arr 7 int get_element int arr 2 return array 1 6 284 invalid dimension Parser This is an internal compiler error Contact HI TECH Software technical support with details 320 Error and Warning Messages 285 no identifier in declaration Parser The identifier is missing in this declaration This error can also occur where the compiler has been confused by such things as missing closing braces e g void interrupt void what is the name of this function 286 declarator too complex Parser This declarator is too complex for the compiler to handle Examine the declaration and find a way to simplify it If the compiler finds it too complex so will anybody maintaining the code 287 arrays of bits or pointers to bit are illegal Parser It is not legal to have an array of bits or a pointer to bit variable e g bit barray 10 wrong no bit arrays bit bp wrong no pointers to bit variables 288 only functions may be void Parser A variable may not be
69. by and the total sizes of all the psects which are used by the compiled code 104 C Language Features Linking Programs The program statistics shown after the summary provides more concise information based on each memory area of the device This can be used as a guide to the available space left in the device More detailed memory usage information listed in ascending order of individual psects may be obtained by using the PICC32 SUMMARY psect option Generate a map file for the complete memory specification of the program 3 12 1 Replacing Library Modules Although HI TECH C comes with a librarian LIBR which allows you to unpack a library files and replace modules with your own modified versions you can easily replace a library module that is linked into your program without having to do this If you add the source file which contains the library routine you wish to replace on the command line list of source files then the routine will replace the routine in the library file with the same name This method works due to the way the linker scans source and library file When trying to resolve a symbol in this instance a function name the linker first scans all source modules for the definition Only if it cannot resolve the symbol in these files does it then search the library files Even though the symbol may be defined in a source file and a library file the linker will not search the libraries and no multiply defined symbol err
70. contain code that handles printing of decimal integers The code is latter changed and another call to printf is added The new call looks like printf output is 6d Now the compiler will detect that in addition there must be code present in the doprnt module that handles integers printed to a specific width The code that handles this flag will be introduced into the doprnt module The size of the doprnt module will increase as more print f features are detected If the format string in a call to printf is not a string literal as in the tutorial but is rather a pointer to a string then the compiler will not be able to reliably predict the printf usage and so it forces a more complete version of printf to be generated However even without being able to scan printf placeholders the compiler can still make certain assumptions reagarding the usage of the function In particular the compiler can look at the number and type of the additional arguments to printf those following the format string expression to determine which placeholders could be valid This enables the size and complexity of the generated printf routine to be kept to a minimum TUTORIAL PRINTF WITHOUT LITERAL FORMAT STRINGS If there is only one reference to printf in a program and it appears as in the following code void my_print const char mes printf mes the compiler cannot determine the exact format string but can see that there are no additional
71. cre teroarea ype ea A me RO 94 31042 Undefined Symbols cs g 544k Oe ee ee Ra a ee 95 PIEDIOCSESIDE o o cs il e Se Re A ee eee a eae ee eS 96 ILLA C Language Comments 2 2 gaio ede ee be ehh eo bebe se 96 3 11 2 Preprocessor Directives io sorc A eR A ka a 97 3113 Predefined Macros s lt 4 bee koe ee EER Re ee we Eo 97 3114 Pragma DITECUVES sc c escorta betua a eA we we 100 3 11 4 1 The pragma jis and nojis Directives 100 3 11 4 2 The pragma printf check Directive 100 3 11 4 3 The pragma regsused Directive 101 3 11 4 4 The pragma switch Directive o 101 3 11 4 5 The pragma warning Directive 102 LinkinS Programs cosida a le OE P a 104 2121 Replacing Library Modules zos ramas a es e y 105 3 12 2 Signature Checking so eto ee AA ee ee a a ee 105 3 12 3 Linker Defined Symbols aR eS 107 Standard I O Functions and Serial VO oo 107 CONTENTS CONTENTS 4 Macro Assembler 109 4 1 Assembler Usate o oia San GG a a pod a Uk amp a 109 42 Assembler ONOS 545 24h i eee bak he eh ee PED ew ees 110 43 HIETECH C Assembly Language 2 5 404 ee eae ee ew eS 113 4 3 1 Predefined Mactos oe o 4 24044286448 e4 oes ee eet ee es 113 4 3 1 1 MIPS32r2 In built Macro Instructions 113 4 3 1 2 MIPSI6E In built Macro Instructions 113 4 3 2 Instruction Operand Variants gt lt e s oe me sese
72. data typing 117 in line 93 include files 133 initializing bytes 126 words 126 labels 89 114 118 line numbers 112 multi character constants 117 operators 118 psects for 89 radix specifiers 116 relocatable expression 120 repeating macros 130 reserving memory 127 character 117 _chacrter 117 making globally accessable 121 scope 118 121 assembly listings blank lines 135 disabling macro expansion 134 enabling 134 excluding conditional code 134 expanding macros 111 133 generating 112 hexadecimal constants 111 including conditional code 133 new page 135 page length 111 page width 112 radix specification 111 subtitles 135 titles 135 assembly macros 128 character 129 character 129 amp symbol 128 concatenation of arguments 128 quoting characters 129 suppressing comments 128 assert function 184 atan function 185 atan2 function 186 atof function 187 atoi function 188 atol function 189 423 INDEX INDEX auto variable area 81 auto variables 79 Avocet symbol file 147 base specifier see radix specifier bases C source 67 biased exponent 73 big endian format 169 binary constants assembly 117 C 67 bit PSECT flag 123 bit types absolute 70 in assembly 123 bit addressable Registers 70 bit fields 73 initializing 74 unamed 74 blocks see psects bootex psect 86 bootloader 59 166 172 bootloaders 170 bsearch function 190 bss p
73. different generated code to non volatile objects For ex ample when assigning a non volatile object the value 1 the object may be cleared and then 75 Supported Data Types and Variables C Language Features incremented but the same operation performed on a volatile object will load the W register with 1 and then store this to the appropriate address Objects that are not qualified volatile may be removed by the compiler if they not used in C or assemby code 3 3 10 Special Type Qualifiers HI TECH C PRO for the PIC32 MCU Family supports the special type qualifiers persistent sfr and cp0 to allow the user to control placement of static and extern class variables into particular address spaces If the PICC32 option STRICT is used these type qualifiers are changed to __persistent _ sfr and __cp0 This type qualifier may also be applied to pointers These types of qualifiers may not be used on variables of class auto if used on variables local to a function it must be combined with the static keyword For example you may not write void test void persistent int intvar WRONG other code because intvar is of class auto To declare intvar as a persistent variable local to function test write static persistent int intvar Variables qualified as sfr or cp0 must also be 4 byte unsigned integers assigned an absolute address Additionally variables qualifed as cp0 have other requirements as detailed below 3 3
74. done using unsigned int in this case and the body of the if would not be executed 83 Operators C Language Features Another problem that frequently occurs is with the bitwise compliment operator This operator toggles each bit within a value Consider the following code unsigned char count c c 0x55 1f c OxAA count If c contains the value 55h it often assumed that c will produce AAh however the result is FFAAh and so the comparison above would fail The compiler may be able to issue a mismatched compari son error to this effect in some circumstances Again a cast could be used to change this behaviour The consequence of integral promotion as illustrated above is that operations are not performed with char type operands but with int type operands However there are circumstances when the result of an operation is identical regardless of whether the operands are of type char or int In these cases HI TECH C PRO for the PIC32 MCU Family will not perform the integral promotion so as to increase the code efficiency Consider the following example unsigned char a b C a b C Strictly speaking this statement requires that the values of b and c should be promoted to unsigned int the addition performed the result of the addition cast to the type of a and then the assignment can take place Even if the result of the unsigned int addition of the promoted values of b and c was different to the result of
75. else keyword has been encountered that cannot be associated with an if statement This may mean there is a missing brace or other syntactic error e g here is a comment which 1 have forgotten to close if a gt b c 0 that will be closed here thus removing the if else my if has been lost c Oxff 249 probable missing in previous block Parser The compiler has encountered what looks like a function or other declaration but the preceding function has not been ended with a closing brace This probably means that a closing brace has been omitted from somewhere in the previous function although it may well not be the last one e g 313 Error and Warning Messages void set char a PORTA a the closing brace was left out here void clear void error flagged here PORTA 0 251 array dimension redeclared Parser An array dimension has been declared as a different non zero value from its previous declaration It is acceptable to redeclare the size of an array that was previously declared with a zero dimension but not otherwise e g extern int array 5 int array 10 oops has it 5 or 10 elements 252 argument conflicts with prototype Parser The argument specified argument 0 is the left most argument of this function definition does not agree with a previous prototype for this function e g this is supposedly calc s prototype
76. generated The dependency file lists those files on which the source file is dependant Dependencies result when one file is included into another 2 6 50 SERIAL hexcode address Store a Value at this Program Mem ory Address This option allows a hexadecimal code to be stored at a particular address in program memory A typical application for this option might be to position a serial number in program memory The byte width of data to store is determined by the byte width of the hexcode parameter in the option A label __serial0 is defined by the runtime startup code that marks the position of the hexadec imal code This symbol may be referenced by C or assembly code in the usual way 61 PICC32 Driver Option Descriptions PICC32 Command line Driver For example to store the one byte value 0 at program memory address 1000h use the option SERIAL 00 1000 Use the option SERIAL 00000000 1000 to store the same value as a four byte quantity This option is functionally identical to the corresponding hexmate option For more detailed information and advanced controls that can be used with this option refer to Section 5 14 1 15 of this manual 2 6 51 SETOPTION app file Set the Command line Options for Ap plication This option is used to supply alternative command line options for the named application when com piling The app component specifies the application that will recieve the new options The file component specifies
77. generates these assembler directives whenever it encounters global C objects At the C source level this means all names which have storage class external and which are not declared 138 Linker and Utilities Link and load addresses as static These symbols may be referred to by modules other than the one in which they are defined It is the linker s job to match up the definition of a global symbol with the references to it Other symbols local symbols are passed through the linker to the symbol file but are not otherwise processed by the linker 5 6 Link and load addresses The linker deals with two kinds of addresses link and load addresses Generally speaking the link address of a psect is the address by which it will be accessed at run time The load address which may or may not be the same as the link address is the address at which the psect will start within the output file HEX or binary file etc In the case of the 8086 processor the link address roughly cor responds to the offset within a segment while the load address corresponds to the physical address of a segment The segment address is the load address divided by 16 Other examples of link and load addresses being different are an initialised data psect that is copied from ROM to RAM at startup so that it may be modified at run time a banked text psect that 1s mapped from a physical load address to a virtual link address at run time The exact manner in
78. given in Table 4 10 and each is described further below 4 3 11 1 ASMOPT_ON From this point onwards in the current module within the current psect instruct the assembler to perform optimisations unless of course assembler optimisations have been turned off with the driver option opt 132 Macro Assembler HI TECH C Assembly Language 4 3 11 2 ASMOPT_OFF From this point onwards in the current module within the current psect instruct the assembler to not perform optimisations even if assembler optimisations have been turned on with the driver option opt 4 3 11 3 FORCE EXTEND Forces the assembler from this point onwards in the current module within the current psect to always extend any MIPS 16e instructions that are extensible whether it is required or not 4 3 11 4 NEVER EXTEND Forces the assembler from this point onwards in the current module within the current psect to never extend any MIPS 16e instructions that are extensible whether it is safe to do so or not 4 3 11 5 AUTO_EXTEND From this point onwards in the current module within the current psect let the assembler decide whether or not extension of any MIPS 16e instructions is necessary 4 3 11 6 COND Any conditional code will be included in the listing output See also the NOCOND control in Section 4 3 11 10 4 3 11 7 EXPAND When EXPAND is in effect the code generated by macro expansions will appear in the listing output See also the NOEXPAND control in Sectio
79. gt void main void char buf 35 7 23 27 char end double inl in2 inl strtod buf send in2 strtod end NULL printf in comps f See Also atof 268 Library Functions Return Value Returns a double representing the floating point value of the converted input string 269 Library Functions STRTOL Synopsis include lt stdlib h gt double strtol const char s const char res int base Description Parse the string s converting it to a long integer type This function converts the first occurence of a substring of the input that is made up of characters of the expected form after skipping leading white space characters The radix of the input is determined from base If this is zero then the radix defaults to base 10 If res is not NULL it will be made to point to the first character after the converted sub string Example include lt stdio h gt include lt strlib h gt void main void char buf 0X299 0x792 char end long inl in2 inl strtol buf send 16 in2 strtol end NULL 16 printf in decimal ld ld n inl in2 See Also strtod 270 Library Functions Return Value Returns a long int representing the value of the converted input string using the specified base 271 Library Functions STRTOK Synopsis include lt string h gt char strtok char sl const char s2 Description A
80. gt void main void double f f ldexp 1 0 10 printf 1 0 2 10 f n See Also frexpO Return Value The return value is the integer i added to the exponent of the floating point value f 217 Library Functions LDIV Synopsis include lt stdlib h gt ldiv_t ldiv long number long denom Description The Idiv routine divides the numerator by the denominator computing the quotient and the remain der The sign of the quotient is the same as that of the mathematical quotient Its absolute value is the largest integer which is less than the absolute value of the mathematical quotient The IdivQ function is similar to the div function the difference being that the arguments and the members of the returned structure are all of type long int Example include lt stdlib h gt include lt stdio h gt void main void ldiv_t lt lt ldiv 1234567 12345 printf Quotient ld remainder ld n lt quot lt rem See Also div uldiv udiv Return Value Returns a structure of type Idiv_t 218 Library Functions LOCALTIME Synopsis include lt time h gt struct tm localtime time_t t Description The localtime function converts the time pointed to by t which is in seconds since 00 00 00 on Jan 1 1970 into a broken down time stored in a structure as defined in time h The routine localtime takes into account the contents of the global in
81. i 0 i lt 180 0 i 10 printf tan 3 0f f n i tan i C See Also sin cos asin acos atan atan2 Return Value The tangent of f 274 Library Functions TIME Synopsis include lt time h gt time_t time time_t t Description This function is not provided as it is dependant on the target system supplying the current time This function will be user implemented When implemented this function should return the current time in seconds since 00 00 00 on Jan 1 1970 If the argument t is not equal to NULL the same value is stored into the object pointed to by t Example include lt stdio h gt include lt time h gt void main void time_t clock time amp clock printf Ss ctime amp clock See Also ctime gmtime localtime asctime Return Value This routine when implemented will return the current time in seconds since 00 00 00 on Jan 1 1970 275 Library Functions Note The time routine is not supplied if required the user will have to implement this routine to the specifications outlined above 276 Library Functions TOLOWER TOUPPER TOASCII Synopsis include lt ctype h gt char toupper int c char tolower int c char toascii int c Description The toupper function converts its lower case alphabetic argument to upper case the tolower routine performs the reverse conversion and the toas
82. if strcmp buffer exit 0 break cputs Type exit to finish n See Also getch getche putch cputs 193 Library Functions Return Value The return value is the character pointer passed as the sole argument 194 Library Functions COS Synopsis include lt math h gt double cos double f Description This function yields the cosine of its argument which is an angle in radians The cosine is calculated by expansion of a polynomial series approximation Example include lt math h gt include lt stdio h gt define C 3 141592 180 0 void main void double i for i 0 i lt 180 0 i 10 printf sin 3 0f f See Also sin tan asin acos atan atan2 Return Value A double in the range 1 to 1 COS Sn i sin i C cos 1 C 195 Library Functions COSH SINH TANH Synopsis include lt math h gt double cosh double f double sinh double f double tanh double f Description These functions are the implement hyperbolic equivalents of the trigonometric functions cos sin and tan Example include lt stdio h gt include lt math h gt void main void printf sf n cosh 1 5 printf s5fin sinh 1 5 printf f n tanh 1 5 Return Value The function cosh returns the hyperbolic cosine value The function sinh returns the hyperbolic sine value The function tanh
83. init_flag will be globally visible but located within the same psect A function may return a bit object by using the bit keyword in the functions prototype in the usual way The bit return value will be returning in the carry flag in the status register Bit variables behave in most respects like normal unsigned char variables but they may only contain the values 0 and 1 and therefore provide a convenient and efficient method of storing boolean flags without consuming large amounts of internal RAM It is however not possible to declare pointers to bit variables or statically initialise bit variables Operations on bit objects use the Bit Field instructions ext and ins thus the generated code to access bit objects requires more instructions than other data types Note that when assigning a larger integral type to a bit variable only the least significant bit is used For example if the bit variable bitvar was assigned as in the following int data 0x54 bit bitvar bitvar data it will be cleared by the assignment since the least significant bit of data is zero If you want to set a bit variable to be 0 or 1 depending on whether the larger integral type is zero false or non zero true use the form bitvar data 0 The psects in which bit objects are allocated storage are declared using the bit PSECT directive flag Eight bit objects will take up one byte of storage space which is indicated by the psect s scale value of
84. installed to ensure the desired compiler is being executed The chip selected with the CHIP option should appear after the Machine type entry The Object code version relates to the file format used by relocatable object files produced by the assembler Unless either the assembler or linker have been updated independently this should not be of concern A typical map file may begin something like the following This example has been cut down for clarity and brevity and should not be used for reference HI TECH Software PICC Compiler std V9 60 Linker command line edf C Program Files HI TECH Software pic std 9 60 dat en_msgs txt h conv sym z Q16F73 ol obj Mconv map ver PICC std V9 60 A 149 Map Files Linker and Utilities ACODE 00h 07FFhx2 ACONST 00h 0FFhx16 ASTRING 00h OFFhx16 A ABANK0 020h 07Fh ABANK1 0A0h 0FFh A preset_vec 00h intentry intcode ppowerup CODE pintsave_0 07Fh prbit_0 BANKO rbss_0 BANKO rdata_0 BANK0 idata_0 CODE C DOCUME 1 user LOCALS 1 Temp cgta5eHNF obj conv obj C Program Files HI TECH Software pic std 9 60 lib pic412 c lib A C Program Files HI TECH Software pic std 9 60 lib pic20 u lib Object code version is 3 9 Machine type is 16F73 The Linker command line shown is the entire list of options and files that were passed to the linker for the build recorded by this map file Remember these are linker options and not command line driver options Typically the first options rel
85. internal compiler error Contact HI TECH Software technical support with details 1121 expression error Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 1137 match error Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 1157 W register must be W9 Assembler The working register required here has to be W9 but an other working register was selected 1159 W register must be W11 Assembler The working register required here has to be W11 but an other working register was selected 1178 the option has been removed and has no effect Driver This option no longer exists in this version of the compiler and has been ignored Use the compiler s help option or refer to the manual to find a replacement option 1179 interrupt level for function may not exceed Code Generator The interrupt level for the function specified is too high Each interrupt function is assigned a unique interrupt level This level is considered when analysing the call graph and re entrantly called functions If using the interrupt_level pragma check the value specified 1180 directory does not exist Driver The directory specified in the setup option does not exist Create the directory and try again 1182 near variables must be global or static Code Generator A variable qualified as near must a
86. k 144 MIO SOOUGUIC owe eh ae Bae aok a eo ee eS ee RB eR EE 144 SpA A a RN a A a a ae 144 Sal QPPOCESSOF 0 ac GS WR ge he a A E ths 146 Die Bp ean othe ee Baie Bh eed Awe bee SA SS i ei 146 DLL SCLASSSUE DOUN ses ap oe ee OR ee SE Re ee a 146 dt IDOL ce ate os A bre Re ee hee Se a gt Be Sd 147 DAS VAMP os de bee eRe eee Gabe da ges dr des 4 147 SO WHR bw ee a dtd es Gea ee eA amp hk RES dG 147 gt a a Se ee al NE a a a ee ae E 147 o Sie book 5 Rh RA cg Sek Ge RR aL gtd Bee a OR Ag a A ee th 147 Iivokine the Linker cs Be eed oe bE eM SE Ea Se eS 148 Map Riles Coss eap ee A AR A Soe Dee EE A AS 148 Datel MGBNEEANIOR a o IS bra EM ee A Be Os 148 DBZ COMMS sr ee ba ds book E A 149 3 9 2 1 General Information c s sos s e ae eap eee a oea 149 5 9 2 2 Psect Information listed by Module 151 5 9 2 3 Psect Information listed by Class 2 we ee ea 153 539 24 Segment Listing 0 6 ise ces e E R e a a 153 5 9 25 Unused Address Ranges oos ees yocp ora a a ER 153 31 20 Symb KDE lt a eaa a ee ee e 154 LIDNAN 24 5 ce kea ea a ee Re a da ges dr Lee A 155 510 1 The Library Format s o opece bh Aa ek ae wa a e e eB eR SE 155 3 102 Using the Liban oe ccs 2405 Ga ae ya e e ee E o E 156 3 103 BXAMpleS sl sorca doles Sow a be OR a eA Bh ge 157 5 10 4 Supplying Arguments 157 3 103 Listing Formal bo ck Ree ee ee ee A RS 157 CONTENTS CONTENTS 512 5 14 5 10 6 Ordering of LID
87. macro definition of defined by Preprocessor The named macro has been defined in such a manner that expanding it causes a recursive expansion of itself 116 end of file within preprocessor macro argument from line Preprocessor A macro argument has not been terminated This probably means the closing parenthesis has been omitted from a macro invocation The line number given is the line where the macro argument started e g define FUNC a b func a b FUNC 5 6 oops where is the closing bracket 117 misplaced constant in if Preprocessor A constant in a if expression should only occur in syntactically correct places This error is most probably caused by omission of an operator e g if FOO BAR oops did you mean if FOO BAR 118 stack overflow processing if expression Preprocessor The preprocessor filled up its expression evaluation stack in a if expression Simplify the expres sion it probably contains too many parenthesized subexpressions 119 invalid expression in if line Preprocessor This is an internal compiler error Contact HI TECH Software technical support with details 291 Error and Warning Messages 120 operator in incorrect context Preprocessor An operator has been encountered in a if expression that is incorrectly placed e g two binary operators are not separated by a value e g if FOO BAR what is 2 d
88. modelled ensure any symbol used to hold arguments to the routine is globally accessible ensure any symbol used to hold a return value is globally accessible optionally use a signature value to enable type checking of parameters when the function is called write the routine ensuring arguments are read from the correct location and the return value is loaded to the correct storage location before returning ensure any local variables required by the routine have space reserved by the appropriate directive A mapping is performed on the names of all C functions and non static global variables See 3 10 3 for a description of mappings between C and assembly identifiers TUTORIAL C CALLABLE ASSEMBLY ROUTINES An assembly routine is required which can add two 16 bit values together The routine must be callable from C code Both the values are passed in as arguments when the routine is called from the C code The assembly routine should return the result of the addition as a 16 bit quantity Most compiler generated executable code is placed in a psect called text 32 or text16 for mips16e functions see Section 3 8 1 As we do not need to have this assembly routine linked at any particular location we can use this same psect so the code is bundled with other executable code and stored at any location in the program space 89 Mixing C and Assembly Code C Language Features This way we do not need to use any additional linker options S
89. non reentrant function Contact HI TECH Support if this is not handwritten assembler code 471 recursive function calls Linker These functions or function call each other recursively One or more of these functions has stat ically allocated local variables compiled stack Either use the reentrant keyword if supported with this compiler or recode to avoid recursion e g int test int a if a 5 recursion may not be supported by some compilers return test a return 0 472 non reentrant function appears in multiple call graphs rooted at and Linker This function can be called from both main line code and interrupt code Use the reentrant key word if this compiler supports it or recode to avoid using local variables or parameters or duplicate the function e g void interrupt my_isr void scan 6 scan is called from an interrupt function 350 Error and Warning Messages void process int a scan a scan is also called from main line code 474 no psect specified for function variable argument allocation Linker The FNCONF assembler directive which specifies to the linker information regarding the auto parameter block was never seen This is supplied in the standard runtime files if necessary This error may im ply that the correct run time startup module was not linked Ensure you have used the FNCONF directive if the runtime startup modul
90. od vs 45 2 6 7 L option Adjust Linker Options Directly 45 2 6 8 Mfile Generate Map File 2 5 osos roer 47 269 Nsa wet dentier Length ec po be Se ee a Pe eS 47 20 10 9 61 fe Specify Output File oc 246 24204040544 4804 o 340s 47 20 11 F Preprocess Assembly Files o cc ee he ee A A 48 26 12 D Quiet Mode ss ee we ER AS we a HH REDS SS 48 2 6 13 5 Compile to Assembler Cod os ee ee ee eS 48 2 6 14 Umacro Undefine a Macro o seoce eang eee ee 48 2 6 15 V Verbose Compile sa ecs eeu dra Re a aw 49 26 16 X Strip Local Symbols lt s races pem a eb a ee DE Pe RS 49 2 6 17 ASMLIST Generate Assembler LST Files 2 2 eee eee 49 2 6 18 CALLGRAPH type Select callgraph type 49 2 6 19 CHECKSUM start end destination lt specs gt Calculate a check SUM fe ee eA ar Re ee do a Boe eae eS 50 2 6 20 CHIP processor Define Processor 02000 50 2 6 21 CHIPINFO Display List of Supported Processors 50 2 6 22 CR fi 1e Generate Cross Reference Listing gt c o c cmoa eck 50 2 6 23 DEBUGGER t ype Select Debugger Type 51 2 6 24 ECHO Echo command line before processing 51 CONTENTS CONTENTS 2 6 25 ERRFORMAT format Define Format for Compiler Messages 51 2 6 26 ERRORS number Maximum Number of Errors 51 2 6 27 FILL opcode Fill Unused Program Memory
91. of segments A segment is conceptual grouping of contiguous psects and are used by the linker as an aid in psect placement There is no segment assembler directive and segments cannot be controlled in any way This section is heralded by the line that contains the headings SEGMENTS Name Load Length Top Selector Space Class The name of a segment is derived from the psect in the contiguous group with the lowest link address This can lead to confusion with the psect with the same name Do not read psect information from this section of the map file Typically this section of the map file can be ignored by the user 5 9 2 5 Unused Address Ranges The last of the memory summaries Just before the symbol table in the map file is a list of memory which was not allocated by the linker This memory is thus unused The linker is aware of any memory allocated by the code generator for absolute variables and so this free space is accurate This section follows the heading UNUSED ADDRESS RANGES 153 Map Files Linker and Utilities and is followed by a list of classes and the memory still available in each class defined in the program If there is more than one range in a class each range is printed on a separate line Any paging boundaries within a class are ignored and not displayed in any way Note that classes often define memory that is also covered by other classes thus the total free space in a memory area is not simply the addition
92. of the size of all the ranges indicated For example if there are two classes the cover the RAM memory RAM and BANKRAM and the first 100h out of 500h bytes are used then both will indicate 000100 0004FF as the unused memory 5 9 2 6 Symbol Table The final section in the map file list global symbols that the program defines This section has a heading Symbol Table and is followed by two columns in which the symbols are alphabetically listed As always with the linker any C derived symbol is shown with its assembler equivalent symbol name The symbols listed in this table are e Global assembly labels e Global EQU SET assembler directive labels and e Linker defined symbols Assembly symbols are made global via the GLOBAL assembler directive see Section 4 3 10 1 for more information linker defined symbols act like EQU directives however they are defined by the linker during the link process and no definition for them will appear in any source or intermediate file Non static C functions and non auto and non static C variables directly map to assembly labels The name of the label will be the C identifier with a leading underscore character The linker defined symbols include symbols used to mark the bounds of psects See Section 3 12 3 The symbols used to mark the base address of each functions auto and parameter block are also shown Although these symbols are used to represent the local autos and parameters of a functi
93. of y x 186 Library Functions ATOF Synopsis include lt stdlib h gt double atof const char s Description The atof function scans the character string passed to it skipping leading blanks It then converts an ASCII representation of a number to a double The number may be in decimal normal floating point or scientific notation Example include lt stdlib h gt include lt stdio h gt void main void char buf 80 double i gets buf i atof buf printf Read s converted to f n buf i See Also atoi atol strtod Return Value A double precision floating point number If no number is found in the string 0 0 will be returned 187 Library Functions ATOI Synopsis include lt stdlib h gt int atoi const char s Description The atoi function scans the character string passed to it skipping leading blanks and reading an optional sign It then converts an ASCII representation of a decimal number to an integer Example include lt stdlib h gt include lt stdio h gt void main void char buf 80 ints 14 gets buf 1 atoi buf printf Read s converted to d n buf i See Also xtoi atof atolQ Return Value A signed integer If no number is found in the string 0 will be returned 188 Library Functions ATOL Synopsis include lt stdlib h gt long atol const char s Description The
94. one null relocation record for each relocation record in the input 5 7 16 LM Similar to the above option this preserves relocation records in the output file but only segment relocations This is used particularly for generating exe files to run under DOS 5 7 17 Mmapfile This option causes the linker to generate a link map in the named file or on the standard output if the file name is omitted The format of the map file is illustrated in Section 5 9 5 7 18 N Ns and Nc By default the symbol table in the link map will be sorted by name The N option will cause it to be sorted numerically based on the value of the symbol The Ns and Nc options work similarly except that the symbols are grouped by either their space value or class 5 7 19 Ooutfile This option allows specification of an output file name for the linker The default output file name is 1 0b3 Use of this option will override the default 5 7 20 Pspec Psects are linked together and assigned addresses based on information supplied to the linker via P options The argument to the P option consists basically of comma separated sequences thus 144 Linker and Utilities Operation Ppsect 1nkaddr min ldaddr min psect 1nkaddr ldaddr There are several variations but essentially each psect is listed with its desired link and load ad dresses and a minimum value All values may be omitted in which case a default will apply depending on previous va
95. option mentioned above to specify unsigned char as default is used 3 3 5 16 Bit Integer Data Types HI TECH C PRO for the PIC32 MCU Family supports 2 16 bit integer types short is a 16 bit two s complement signed integer type representing integral values from 32 768 to 32 767 inclusive Unsigned short is a 16 bit unsigned integer type representing integral values from 0 to 65 535 inclusive All 16 bit integer values are represented in little endian format with the least significant byte at the lower address 71 Supported Data Types and Variables C Language Features Variables may be declared using the signed short int and unsigned short int keyword sequences respectively to hold values of these types When specifying a short int type the keyword int may be omitted Thus a variable declared as short will containa signed short int and a variable declared as unsigned short will contain an unsigned short int 3 3 6 32 Bit Integer Data Types and Variables HI TECH C PRO for the PIC32 MCU Familysupports four 32 bit integer types Long and int are 32 bit two s complement signed integer types representing integral values from 2 147 483 648 to 2 147 483 647 inclusive Unsigned long and unsigned int are 32 bit unsigned integer types representing integral values from 0 to 4 294 967 295 inclusive All 32 bit integer values are repre sented in little endian format with the least significant word and least significant byte at the lowest
96. option can be used more than once if multiple directories are to be searched The default include directory containing all standard header files is always searched even if no I option is present The default search path is searched after any user specified directories have been searched For example PICC32 CHIP 32MX360F512L C Ic include Id myapp include test c will search the directories c include and d myapp include for any header files included into the source code then search the default include directory the include directory where the compiler was installed It is strongly advised not to use I to add the compiler s default include path not only because it is unnecessary but in the event that the build tool changes the path specified here will be searched prior to searching the new compiler s default path This option has no effect for files that are included into assembly source using the INCLUDE directive See Section 4 3 11 8 44 PICC32 Command line Driver PICC32 Driver Option Descriptions 2 6 6 Llibrary Scan Library The L option is used to specify additional libraries which are to be scanned by the linker and code generator Libraries specified using the L option are scanned before any C standard libraries The argument to L is a library keyword to which the prefix pic32 and other letters and digits as described in Section 2 3 1 are added Both a p code and object code library filename is generate
97. order to make the library concept useful it is necessary for the linker to treat modules in a library differently from object files If an object file is specified to the linker it will be linked into the final linked module A module in a library however will only be linked in if it defines one or more symbols previously known but not defined to the linker Thus modules in a library will be linked only if required Since the choice of modules to link is made on the first pass of the linker and the library is searched in a linear fashion it is possible to order the modules in a library to produce special effects when linking More will be said about this later 5 10 1 The Library Format The modules in a library are basically just concatenated but at the beginning of a library is main tained a directory of the modules and symbols in the library Since this directory is smaller than the sum of the modules the linker can perform faster searches since it need read only the directory and not all the modules on the first pass On the second pass it need read only those modules which are required seeking over the others This all minimises disk I O when linking It should be noted that the library format is geared exclusively toward object modules and is not a general purpose archiving mechanism as is used by some other compiler systems This has the advantage that the format may be optimized toward speeding up the linkage process 155 Libra
98. passing that option to the HELP option 1033 available command line options Hexmate This is a simple heading that appears before the list of available options for this application 1034 type for available options Hexmate It looks like you need help This advisory suggests how to get more information about the options available to this application or the usage of these options 1035 bad argument count Parser The number of arguments to a function is unreasonable This is an internal compiler error Contact HI TECH Software technical support with details 1036 bad optional header length 0x expected Cromwell The length of the optional header in this COFF file was of an incorrect length 1037 short read on Cromwell When reading the type of data indicated in this message 1t terminated before reaching its specified length 1038 string table length too short Cromwell The specified length of the COFF string table is less than the minimum 1039 inconsistent symbol count Cromwell The number of symbols in the symbol table has exceeded the number indicated in the COFF header 1040 bad checksum record 0x checksum 0x Cromwell A record of the type specified failed to match its own checksum value 400 Error and Warning Messages 1041 short record Cromwell While reading a file one of the file s records ended short of its specified length 1042 unknown recor
99. processor section with multiple ZEROREG values Only one ZEROREG value is allowed If you have not manually edited the chip info file contact HI TECH Support with details 820 duplicate SPAREBIT for in chipinfo file at line Assembler The chipinfo file has a processor section with multiple SPAREBIT values Only one SPAREBIT value is allowed If you have not manually edited the chip info file contact HI TECH Support with details 822 duplicate ROMSIZE for in chipinfo file at line Assembler The chipinfo file has a processor section with multiple ROMSIZE values Only one ROMSIZE value is allowed If you have not manually edited the chip info file contact HI TECH Support with details 824 duplicate LIB for in chipinfo file at line Assembler The chipinfo file has a processor section with multiple LIB values Only one LIB value is allowed If you have not manually edited the chip info file contact HI TECH Support with details 829 unrecognized line in chipinfo file at line Assembler The chipinfo file contains a processor section with an unrecognised line Contact HI TECH Support if the INI has not been edited 830 missing ARCH specification for in chipinfo file Assembler The chipinfo file has a processor section without an ARCH values The architecture of the processor must be specified Contact HI TECH Support if the chipinfo file has not been modified 832 empty chip info file Assembler
100. rbit psect displays the Link address converted to byte units i e 50h 8 gt Ah The list of files that make up the program indicated in this section of the map file will typically consist of one or more object files derived from input source code The map file produced by PRO compilers will show one object file derived from all C source modules however Standard version compilers will show one object file per C source module In addition there will typically be the runtime startup module The runtime startup code is precompiled into an object file in the case of Standard version compilers or is a compiler written assembler source file which is then compiled along with the remainder of the program In either case an object file module will be listed in this section along with those psects which it defines If the startup module is not being deleted after compilation see the RUNTIME option in Section 2 6 48 then the module name will be startup obj otherwise this module will have a system dependent temporary file name stored in a system dependent location Modules derived from library files area also shown in this list The name of the library file is printed as a header followed by a list of the modules that contributed to the output Only mod ules that define symbols that are referenced are included in the program output For example the following C program files HI TECH Software PICC 18 9 50 lib pic861l c lib ilaldiv obj text 17
101. setting 147 warning message format 64 warnings level displayed 64 suppressing 147 with PSECT flag 124 word addresses 168 word boundaries 124 XREF assembler control 135 xtoi function 285 437 INDEX INDEX 438 PICC32 Command line Options Option Meaning Compile to object files only Dmacro Define preprocessor macro E file Redirect and optionally append errors to a file Gfile Generate source level debugging information Ipath Specify a directory pathname for include files Llibrary Specify a library to be scanned by the linker L option Specify option to be passed directly to the linker Mfile Request generation of a MAP file Nsize Specify identifier length Ofile Output file name P Preprocess assembler files 0 Specify quiet mode So Compile to assembler source files only Usymbol Undefine a predefined preprocessor symbol V Verbose display compiler pass command lines X Eliminate local symbols from symbol table ASMLIST Generate assembler LST file for each compilation CALLGRAPH t ype Select Callgraph type CHECKSUM start end destinati o alculate a Checksum lt specs gt CHIP processor Selects which processor to compile for CHIPINFO Displays a list of supported processors CODEOFFSET address Offset program code to address CR file Generate cross reference listing DEBUGGER t ype Select the d
102. space 390 missing argument to P Linker There have been too many p options passed to the linker or a p option was not followed by any arguments The arguments of separate p options may be combined and separated by commas 391 missing argument to Q Linker The linker option requires the machine type for an argument 392 missing argument to U Linker The U undefine option needs an argument 393 missing argument to W Linker The W option listing width needs a numeric argument 394 duplicate D or H option Linker The symbol file name has been specified to the linker for a second time This should not occur if you are using a compiler driver If invoking the linker manually ensure that only one instance of either of these options is present on the command line 395 missing argument to J Linker The maximum number of errors before aborting must be specified following the j linker option 340 Error and Warning Messages 397 usage hlink options files obj files lib Linker Improper usage of the command line linker If you are invoking the linker directly then please refer to Section 5 7 for more details Otherwise this may be an internal compiler error and you should contact HI TECH Software technical support with details 398 output file can t be also an input file Linker The linker has detected an attempt to write its output file over one of its input files This cannot b
103. stdio h gt include lt time h gt void main void time_t clock struct tm tp time clock tp localtime amp clock printf Ss asctime tp See Also ctime gmtime localtime time 181 Library Functions Return Value A pointer to the string Note The example will require the user to provide the time routine as it cannot be supplied with the compiler See time for more details 182 Library Functions ASIN Synopsis include lt math h gt double asin double f Description The asin function implements the converse of sin i e it is passed a value in the range 1 to 1 and returns an angle in radians whose sine is equal to that value Example include lt math h gt include lt stdio h gt void main void float i a for i 1 0 i lt 1 0 i 0 1 a asin i 180 0 3 141592 printf asin f f degrees n i a See Also sin cos tan acos atan atan2 Return Value An angle in radians in the range 7 183 Library Functions ASSERT Synopsis include lt assert h gt void assert int e Description This macro is used for debugging purposes the basic method of usage is to place assertions liberally throughout your code at points where correct operation of the code depends upon certain conditions being true initially An assert routine may be used to ensure at run time that an assumption holds
104. the address e A psect defined as global will be combined with other global psects of the same name from other modules at link time This is the default behaviour for psects unless the local flag is used e The isa flag indicates what instruction set architecture ISA the executable assembly in the psect if any belongs to See table 4 9 for allowable options to this flag e The limit flag specifies a limit on the highest address to which a psect may extend 123 HI TECH C Assembly Language Macro Assembler A psect defined as local will not be combined with other local psects at link time even if there are others with the same name Where there are two local psects in the one module they reference the same psect A local psect may not have the same name as any global psect even one in another module A psect defined as ovrld will have the contribution from each module overlaid rather than concatenated at runtime ovrld in combination with abs defines a truly absolute psect i e a psect within which any symbols defined are absolute The pure flag instructs the linker that this psect will not be modified at runtime and may therefore for example be placed in ROM This flag is of limited usefulness since it depends on the linker and target system enforcing it The reloc flag allows specification of a requirement for alignment of the psect on a particular boundary e g reloc 100h would specify that this psect must start on an addr
105. the code generator needs to compile all p code or p code library files in the one step Thus if the PASS1 option is not used or PRE is not used all C source files and any p code libraries must be built together in the one command If a compilation is performed and the source file that contains main is not present in the list of C source files an undefined symbol error for _main will be produced by the code generator If the file that contains the definition for main is present but it is a subset of the C source files making up a project that is being compiled the code generator will not be able to see the entire C program and this will defeat most of the optimization techniques employed by the code generator There may be multi step compilation methods employed that lead to compiler errors as a result of the above restrictions for example you cannot have an C function compiled into a p code library that is called only from assembler code 2 2 3 Special Processing There are several special steps that take place during compilation 25 lib Runtime Files PICC32 Command line Driver 2 2 3 1 Printf check An extra execution of the code generator is performed for prior to the actual code generation phase This pass is part of the process by which the printf library function is customized see Section 2 3 4 for more details 2 2 3 2 Assembly Code Requirements After pre processing and parsing of any C source files but be
106. the project by the driver These are e Library files e The runtime startup module e The powerup routine and e The printf routine Strictly speaking the powerup routine is neither compiler generated source nor a library routine It is fully defined by the user however as it is very closely associated with the runtime startup module it is discussed with the other runtime files in the following sections 26 PICC32 Command line Driver Runtime Files By default libraries appropriate for the selected driver options are automatically passed to the code generator and linker Although individual library functions or routines will be linked in once referenced in C code the compiler still requires the inclusion of the appropriate header file for the library function that is being used See the appropriate library function section in Chapter A for the header file that should be used 2 3 1 Library Files By default PICC32 will search the LIB directory of the compiler distribution for several p code and relocatable object library files which are then passed to the code generator and linker respectively These library files typically contain e The C standard library functions e Assembly routines implicitly called by the code generator e Chip specific peripherals functions e Chip specific memory functions These library files are always scanned after scanning any user specified libraries passed to the driver on the command line
107. the resultant string Example include lt string h gt include lt stdio h gt void main void char buffer 256 char sl s2 strcpy buffer Start of line sl buffer s2 end of line strncat s1 s2 5 printf Length d n strlen buffer printf string s n buffer See Also strcpy stremp streat strlen 258 Library Functions Return Value The value of sl is returned 259 Library Functions STRNCMP STRNICMP Synopsis include lt string h gt int strncmp const char sl const char s2 size_t n int strnicmp const char sl const char s2 size_t n Description The strnemp function compares its two null terminated string arguments up to a maximum of n characters and returns a signed integer to indicate whether s1 is less than equal to or greater than s2 The comparison is done with the standard collating sequence which is that of the ASCII character set The strnicmp function is the case insensitive version of this function Example include lt stdio h gt include lt string h gt void main void int i i strcmp abcxyz abcxyz if i 0 printf Both strings are equal n else if i gt 0 printf String 2 less than string lin else printf String 2 is greater than string lin See Also strlen strempQ strepy streat 260 Library Functions Return Value
108. the size of an object and found it to be zero This almost certainly indicates an error in your declaration of a pointer e g you may have declared a pointer to a zero length array In general pointers to arrays are of little use If you require a pointer to an array of objects of unknown length you only need a pointer to a single object that can then be indexed or incremented 762 constant truncated when assigned to bitfield Code Generator A constant value is too large for a bitfield structure member to which it is being assigned e g struct INPUT unsigned a 3 unsigned b 5 input_grp input_grp a 0x12 12h cannot fit into a 3 bit wide object 763 constant left operand to operator Code Generator The left operand to a conditional operator is constant thus the result of the tertiary operator will always be the same e g a 8 b c this is the same as saying a b 764 mismatched comparison Code Generator A comparison is being made between a variable or expression and a constant value which is not in the range of possible values for that expression e g unsigned char c if c gt 300 oops how can this be true close 765 degenerate unsigned comparison Code Generator There is a comparison of an unsigned value with zero which will always be true or false e g unsigned char c if c gt 0 will always be true because an unsigned value can never be less t
109. the user manual for option details Driver An obsolete option was detected Use help or refer to the manual to find a replacement option that will not result in this advisory message 1210 Visit the HI TECH Software website www htsoft com for a possible update Driver Visit our website to see if an update is available to address the issue s listed in the previous compiler message Please refer to the on line self help facilities such as the Frequently asked Questions or search the On line forums In the event of no details being found here contact HI TECH Software for further information 1212 Found 0 IXh at address h Hexmate The code sequence specified in a FIND option has been found at this address 1213 duplicate ARCH for in chipinfo file at line Assembler Driver The chipinfo file has a processor section with multiple ARCH values Only one ARCH value is allowed If you have not manually edited the chip info file contact HI TECH Support with details 407 Error and Warning Messages 1218 can t create cross reference file Assembler The assembler attempted to create a cross reference file but it could not be created Check that the file s pathname is correct 1228 unable to locate installation directory Driver The compiler cannot determine the directory where it has been installed 1230 dereferencing uninitialized pointer Code Generator A pointer that has not yet been assigne
110. this region isn t known until link time Table 2 8 interrupts sub options affecting the location of the vector table 53 PICC32 Driver Option Descriptions PICC32 Command line Driver SUB OPTION MEANING multi default All interrupt service requests will be serviced at a calculated address In all cases the spaceing between vectors in 32 bytes All other exceptions are still serviced at 0x180 from the vector table base single All interrupt service requests will be serviced at one vector address namely 0x200 from the vector table base All other exceptions are still serviced at 0x180 genex All interrupt service requests and exceptions are service at the general exception vector at 0x180 from the vector table base Table 2 9 interrupts sub options affecting the number of vectors to service interrupts Table 2 10 Supported languages Suboption Language en english English fr french francais French de german deutsch German 2 6 32 ISA lt type gt Specify the Instruction Set Architecture The default Instruction Set Architecture for generated code can be set to either MIPS16e or MIPS32r2 The MIPS16e setting can lead to higher code density See the device datasheet for more information PICC32 CHIP 32MX360F512L ISA MIPS16E test c init c The default setting is MIPS32r2 Note that the fucntion qualifiers mips16e and mips32r2 will over
111. too deep The limit is 30 macros and include files nested at one time 774 too many macro parameters Assembler There are too many macro parameters on this macro definition 776 can t allocate space for object offs Assembler The assembler has run out of memory 777 can t allocate space for opnd structure within object offs Assembler The assembler has run out of memory 780 too many psects defined Assembler There are too many psects defined Boy what a program 781 can t enter abs psect Assembler This is an internal compiler error Contact HI TECH Software technical support with details 782 REMSYM error Assembler This is an internal compiler error Contact HI TECH Software technical support with details 783 with psects are cyclic Assembler If Psect A is to be placed with Psect B and Psect B is to be placed with Psect A there is no hierarchy The with flag is an attribute of a psect and indicates that this psect must be placed in the same memory page as the specified psect Remove a with flag from one of the psect declarations Such an assembler declaration may look like psect my_text local class CODE with basecode which will define a psect called my_text and place this in the same page as the psect basecode 379 Error and Warning Messages 784 overfreed Assembler This is an internal compiler error Contact HI TECH Software techni
112. unique assembler generated label in place of more For example down foobar expands to 220001 decfsz foobar goto 0001 if invoked a second time the label more would expand to 0002 129 HI TECH C Assembly Language Macro Assembler 4 3 10 17 ALIGN The ALIGN directive aligns whatever is following data storage or code etc to the specified boundary in the psect in which the directive is found The boundary is specified by a number following the directive and it specifies a number of bytes For example to align output to a 2 byte even address within a psect the following could be used ALIGN 2 Note however that what follows will only begin on an even absolute address if the psect begins on an even address The ALIGN directive can also be used to ensure that a psect s length is a multiple of a certain number For example if the above ALIGN directive was placed at the end of a psect the psect would have a length that was always an even number of bytes long 4 3 10 18 REPT The REPT directive temporarily defines an unnamed macro then expands it a number of times as determined by its argument For example REPT 3 addwf fred w ENDM will expand to addwf fred w addwf fred w addwf fred w 4 3 10 19 IRP and IRPC The IRP and IRPC directives operate similarly to REPT however instead of repeating the block a fixed number of times it is repeated once for each member of an argument list In the case of IRP the lis
113. used to initialize storage as bytes The argument is a list of expressions each of which will be assembled into one byte Each character of the string will be assembled into one memory location Examples alabel DB X 1 2 3 1 Note that because the size of an address unit in ROM is 4 bytes the DB pseudo op will initialise a word with the upper 3 bytes set to zero 4 3 10 8 DH Operates in a similar fashion to DB except that it assembles expressions in half words i e 2 bytes Example DH 0x1234 4 3 10 9 DSTR Used to store the ASCII values of characters of a string without a NULL terminating character Example DSTR Hello 4 3 10 10 DSTRZ Used to store the ASCII values of characters of a string with a NULL terminating character DSTRZ World 4 3 10 11 DW DW operates in a similar fashion to DB except that it assembles expressions in words i e 4 bytes Example DW 1 36641234h A 3777 126 Macro Assembler HI TECH C Assembly Language 43 10 12 DS This directive reserves but does not initialize memory locations The single argument is the number of bytes to be reserved Examples alabel DS 23 Reserve 23 bytes of memory xlabel DS 2 3 Reserve 5 bytes of memory 43 10 13 DABS This directive allows one or more bytes of memory to be reserved at the specified address The general form of the directive is DABS memory_space address bytes where memory_space is a number representing
114. which link and load addresses are used depends very much on the particular compiler and memory model being used 5 7 Operation A command to the linker takes the following form hlink options files Options is zero or more linker options each of which modifies the behaviour of the linker in some way Files is one or more object files and zero or more library names The options recognised by the linker are listed in Table 5 1 and discussed in the following paragraphs Table 5 1 Linker command line options Option Effect 8 Use 8086 style segment offset address form Aclass low high Specify address ranges for a class Cx Call graph options continued ln earlier versions of HI TECH C the linker was called LINK EXE 139 Operation Linker and Utilities Table 5 1 Linker command line options Option Effect Cpsect class Specify a class name for a global psect Cbhaseaddr Produce binary output file based at baseaddr Dclass delta Specify a class delta value Dsymfile Produce old style symbol file Eerrfile Write error messages to errfile F Produce obj file with only symbol records Gspec Specify calculation for segment selectors Hsymfile Generate symbol file H symfile Generate enhanced symbol file I Ignore undefined symbols Jnum Set maximum number of errors before aborting
115. which will display information about operations CROMWELL is performing 5 14 Hexmate The Hexmate utility is a program designed to manipulate Intel HEX files Hexmate is a post link stage utility that provides the facility to e Calculate and store variable length checksum values e Fill unused memory locations with known data sequences e Merge multiple Intel hex files into one output file Convert INHX32 files to other INHX formats e g INHX8M Detect specific or partial opcode sequences within a hex file Find replace specific or partial opcode sequences e Provide a map of addresses used in a hex file e Change or fix the length of data records in a hex file e Validate checksums within Intel hex files Typical applications for hexmate might include 165 Hexmate Linker and Utilities Merging a bootloader or debug module into a main application at build time Calculating a checksum over a range of program memory and storing its value in program memory or EEPROM Filling unused memory locations with an instruction to send the PC to a known location if it gets lost Storage of a serial number at a fixed address Storage of a string e g time stamp at a fixed address Store initial values at a particular memory address e g initialise EEPROM Detecting usage of a buggy restricted instruction Adjusting hex file to meet requirements of particular bootloaders 5 14 1 Hexmate Command Line Options Some of these hexm
116. will cause both text and data to have a link address of zero text will have a load address of 0 and data will have a load address starting after the end of text The bss psect will concatenate with data for both link and load addresses The load address may be replaced with a dot character This tells the linker to set the load address of this psect to the same as its link address The link or load address may also be the name of another already linked psect This will explicitly concatenate the current psect with the previously specified psect e g Ptext 0 data 8000h bss Pnvram bss heap 145 Operation Linker and Utilities This example shows text at zero data linked at 8000h but loaded after text bss is linked and loaded at 8000h plus the size of data and nvram and heap are concatenated with bss Note here the use of two P options Multiple P options are processed in order If A options have been used to specify address ranges for a class then this class name may be used in place of a link or load address and space will be found in one of the address ranges For example ACODE 8000h BFFEh E000h FFFERh Pdata C000h CODE This will link data at COOOh but find space to load it in the address ranges associated with CODE If no sufficiently large space is available an error will result Note that in this case the data psect will still be assembled into one contiguous block whereas other psects in the class CODE will be d
117. 0 filename index out of range in line number record Cromwell The COD file has an invalid value in the specified record 621 error writing ELF DWARF section on Cromwell An error occurred writing the indicated section to the given file Confirm the spelling and path of the file specified on the command line 622 too many type entries Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 623 bad class in type hashing Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 624 bad class in type compare Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 625 too many files in COFF file Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 626 string lookup failed in COFF get_string Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 627 missing in SDB file line column Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 363 Error and Warning Messages 629 bad storage class in SDB file line column Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 630 invalid syntax for prefix list in SDB file Cromwell
118. 0 10 Did you forget the radix GA f 0h 10 436 psect re orged Linker This psect has had its start address specified more than once 344 Error and Warning Messages non 437 missing in class spec Linker A class spec needs an sign e g Ctext ROM See Section 5 7 9 for more information 438 bad size in S option Linker The address given in a S specification is invalid it should be a valid number in decimal octal or hexadecimal radix The radix is specified by a trailing O for octal or H for hex A leading 0x may also be used for hexadecimal Case in not important for any number or radix Decimal is the default e g SCODE f000 Did you forget the radix SCODE f000h 439 bad D spec Linker The format of a D specification giving a delta value to a class is invalid e g DCODE What is the delta value for this class Maybe you meant something like DCODE 2 440 bad delta value in D spec Linker The delta value supplied to a D specification is invalid This value should an integer of base 8 10 or 16 441 bad A spec Linker The format of a A specification giving address ranges to the linker is invalid e g ACODE What is the range for this class Maybe you meant ACODE 0h 1fffh 345 Error and Warning Messages 442 missing address in A spec Linker The format of a A specification giving address ranges to the linker is invalid e g ACODE Wh
119. 000h 5 7 24 Usymbol This option will enter the specified symbol into the linker s symbol table as an undefined symbol This is useful for linking entirely from libraries or for linking a module from a library where the ordering has been arranged so that by default a later module will be linked 5 7 25 Vavmap To produce an Avocet format symbol file the linker needs to be given a map file to allow it to map psect names to Avocet memory identifiers The avmap file will normally be supplied with the compiler or created automatically by the compiler driver as required 5 7 26 Wnum The W option can be used to set the warning level in the range 9 to 9 or the width of the map file for values of num gt 10 W9 will suppress all warning messages W0 is the default Setting the warning level to 9 W 9 will give the most comprehensive warning messages 5 7 27 X Local symbols can be suppressed from a symbol file with this option Global symbols will always appear in the symbol file 5 7 28 Z Some local symbols are compiler generated and not of interest in debugging This option will suppress from the symbol file all local symbols that have the form of a single alphabetic character followed by a digit string The set of letters that can start a trivial symbol is currently k1fLSu The Z option will strip any local symbols starting with one of these letters and followed by a digit string 147 Invoking the Linker Link
120. 12 144 157 opt files 111 p1 files 22 pro files 58 sdb files 36 sym files 35 143 146 psect address symbol 144 comment suppression characters 128 lt gt macro quote characters 129 character in assembly labels 117 nnnn type symbols 118 129 command file specifier 21 asm directive 92 define 42 include directive 20 pragma directives 100 undef 48 character in assembly labels 117 macro argument prefix 129 amp assembly macro concatenation character 128 _ character in assembly labels 117 HTC_VER_MAJOR_ 97 HTC_VER_MINOR_ 97 HTC_VER_PATCH_ 97 _PIC32 97 __ Bxxxx type symbols 107 __ CONFIG macro 66 178 417 _ DATE _ 97 _ FILE_ 97 __Hxxxx type symbols 107 _ LINE _ 97 __Lxxxx type symbols 107 __PICC32__ 97 _ TIME __ 98 __serialO label 61 PICC32 command format 20 abs function 179 abs PSECT flag 123 absolute object files 144 absolute psects 123 124 absolute variables 80 bits 70 accessing SFRs 94 acos function 180 421 INDEX INDEX additional memory ranges 59 addresses byte 168 link 139 144 load 139 144 word 168 addressing unit 123 ALIGN directive 130 alignment within psects 130 ANSI standard conformance 62 divergence from 65 implementation defined behaviour 65 argument area 81 argument passing 81 ASCII characters 71 asctime function 181 asin function 183 asm C directive 92 assembler 109 con
121. 169 SO AELE ee ch Bovine A wh eB oe amp BRS 170 SILL FIND corran dos eee SO oe ws 171 5 1418 lt FIND DELETE ooo c egg SA a Bs a Be he we aes 172 5 14 19 FIND REPLACE gt s cose t eea a Ca ee ew E 172 3141 10 FORMAT o pe bod beh OG Ba Sao E Se hoe a 172 SWAT HELP oso ae hee A ee ae eee ee eee 173 NA LIL LOOP sce 8 ee A A AO 173 CONTENTS CONTENTS A 12 S43 MASK 4s aonb a BA Ree OE a Ba OE eae 174 STD AOE els ee does ee ee ee a 174 5 14 1 15 SERIAL e 6 6 4 4 a Pe ee ba 174 DABA reran a eRe ERE A A Rae oe 175 SGT STRING es paca ne doe om a eG Race 175 5 14 1 18 STRPACK voa wee e Ee ee A ed 176 Library Functions 177 CONFIG 3G 4 bbe ee Pe Ee bbe ee wee hE Ee 178 o io a sae a aa Ges Wea Tam E fb das as Gh sip Be Gord Hock Ses asda dB AGG Us ee hy Seer eden 179 ACOS sc che Ste Bae RS eae BHA ee eae he SEE amp CA we Ed 180 I oo oe te a ees dn ae a AOR Pk Bee GS ee AE de ays 181 AOIN e hy a speach ses lee ects Re heck sheet dhs Bs thy pede we nobel os dee Sap hore Be oe het tas a Js Seed Beha od 183 ASERRE nn eee pe eee Soha See ee ee A E ee bd See ews 184 STAN pote Sack ton oe By aos chek dew Grantee Badok fou Rk Big bd oe be Boars dagen 2 185 ATANI 2 044640 4 e4n Bbw deed Aa eee Shee eA ae ea eee ES 186 AIOP ic kG SS ee eo ER ES aR Ee Bde SS sa 187 PLO is Se O a D Ae Se 188 ATOL 22 4 e 484 2404004 be POA SSA Se RAE EME SERRA EEO 189 BSEARCE us sia la ed A Se ee ee EE A ee es 190 CEIR ooh E Gt D
122. 16bit 78 32 bit 78 function 79 to functions 78 pow function 232 powerup psect 86 powerup routine 29 33 powerup as 33 pragma directives 100 predefined symbols preprocessor 97 preprocessing 48 assembler files 48 preprocessor macros 42 path 44 preprocessor directive asm 92 endasm 92 preprocessor directives 97 in assembly files 114 preprocessor symbols predefined 97 printf format checking 100 printf function 26 printf_check pragma directive 100 PROCESSOR directive 112 processor selection 50 131 146 433 INDEX INDEX processor selections 66 processors adding new 66 program entry point 33 121 program sections 120 project name 21 prototypes for assembly code 89 psect bootex 86 bss 30 86 138 config 86 const 86 data 86 138 idata 29 60 86 init 86 nvbit 76 86 nvram 76 86 nvrram 76 powerup 86 rbit 86 rbss 87 rdata 29 reset 86 text 86 PSECT directive 120 121 PSECT directive flag limit 146 PSECT directive flags 121 434 abs 123 bit 123 class 123 delta 123 global 123 limit 123 local 124 ovrid 124 pure 124 reloc 124 size 124 space 124 with 124 psects 85 120 138 absolute 123 124 aligning within 130 alignment of 124 basic kinds 138 class 141 146 compiler generated 85 default 121 delta value of 142 differentiating ROM and RAM 124 for assembly code 89 linking 137 listing 63 local 1
123. 21 LONGIMP gt cage vee ae a Oe ee eae Ga a ee ear 222 EIDA orero moni g ea aa 224 INTENTE osa hw eee Beet Bi E de be A 225 METIME 6 5 5554 e oe De eee E E ee EP Ae See ow RO 227 Ni ars wn ie Re Maa o e a e di tos Be A Ei 229 POW 225 4 ee be dc bE doe See ee Se bs baw ee ee Ge ek oe F 232 PUTO co ee ebb be bebe GeV a bese eee aE ee Gee 233 PUTCHAR sido ee a Seta eG eee baa ee tee Ga ae Ga A 234 PULS bese a A Se eG Ba BB RAL a he e e 236 WROD o 4 eh ee ee ee Bh ek A e de ee Bi ede ae bk S 237 BAND 300 6S OS OA SE EE A E EE RS SOO SE EE Re a eS 239 ROUND 2 2 amp EA ee Hac Give As es et be o Bes EG 241 BETIMP ooo ea es ga bb dee Lobe ee dor bb eee Ga eS E es 244 PEIVECTOR j4 5650442 PAREN GS Oe eee RR oS eA Ew ios 246 SIN 2G hb 4p gu REM dew Rae RE CANS RE eee bee Pee eee 247 SORT cuina OR A RE BS A RAL a he G 248 SRAN 26 4 eb eee Bae Bae be ee Bae Ses 4 te 249 SURCAD o p C44 k 4S SRS ESAS SORA SE AS OES EEA Oe ee oe eS 250 SUCH e Be es We St Rote a e Bi Ae nase Hae te dd os Be as Wi 251 SIRCMP Losa bb des Loe ee ee bb be bb ees bees oe os 253 STREPY coses be PARED A Oe eee RE ES ea we ee 255 SURCSPN 233 Eee ee a eee Eee Ce a ee ae 256 DEREEM foe SAS a RG aA Bk Ae a G Ao A a ees He ES 257 SIRNCAT coo e Sew eee ee ee Saw a eS 258 SIRNGMP 2 4 4 Nee ee y AR Re Ge Reena E A eae Bes 260 SINCE se alia ee di A ovat ie a eee oe toe amp a eid 262 SURPBRE 0 soe be dan bo des be eee be bs be bees baa oe os 264 SPIRBCHR coa be PRR ERM
124. 2fh in memory space 1 is being used This information is passed to the code generator to ensure that these address spaces are not used by C code The linker will also be told to remove these ranges from those available and this reservation will be observable in the map file The RAM class definition for example may look like ARAM 00h 0FFhx2 0200h 020Fh 0230h 02FFh 0300h 03FFhx3 for an 18F452 device showing that addresses 210h through 22F were reserved from this class range 3 10 4 2 Undefined Symbols Variables can be defined in assembly code if required but in some instances it is easier to do so in C source code in other cases the symbols may need to be accessable from both assembly and C source code A problem can occur if there is a variable defined in C code but is never referenced throughout the entire the C program In this case the code generator may remove the variable believing it is unused If assembly code is relying on this definition an error will result To work around this issue HI TECH C PRO for the PIC32 MCU Family also searches assembly derived object files for symbols which are undefined These will typically be symbols that are used but not defined in assembly code The code generator is informed of these symbols and if they are encountered in the C code the variable is automatically marked as being volatile This is the equivalent of the programmer having qualified the variable as being volatile in the source
125. 3 G 35 44 I 44 L 45 M 47 O 35 S 48 driver options WARNFORMAT format 64 DS directive 127 DW directive 126 ELSE directive 127 ELSIF directive 127 426 embedding serial numbers 174 END directive 33 121 endasm directive 92 ENDIF directive 127 ENDM directive 128 enhanced symbol files 143 environment variable HTC_ERR_FORMAT 38 HTC_MSG_FORMAT 38 HTC_WARN_FORMAT 38 EQU directive 114 125 equating assembly symbols 125 error files creating 142 error messages 43 formatting 38 LIBR 158 eval_poly function 200 exp function 201 EXPAND assembler control 133 exponent 72 expressions assemby 118 relocatable 120 fabs function 202 file extensions 20 file formats assembler listing 49 Avocet symbol 147 command 157 creating with cromwell 162 cross reference 111 160 cross reference listings 50 dependency 61 DOS executable 144 enhanced symbol 143 library 155 157 link 148 INDEX INDEX object 42 144 157 preprocessor 57 prototype 58 specifying 56 symbol 143 symbol files 35 TOS executable 144 files intermediate 55 57 output 56 temporary 55 56 fill memory 165 filling unused memory 52 170 floating point data types 72 biased exponent 73 exponent 73 format 72 mantissa 72 floating suffix 69 floor function 204 fmod function 203 frexp function 205 ftoa function 206 function return values 81 stack frame 82 function pointers 79 fun
126. 38 maximum size of 124 page boundaries and 124 specifying address ranges 146 specifying addresses 141 144 pseudo ops assembler 121 pure PSECT flag 124 putch function 107 233 putchar function 234 puts function 236 qsort function 237 qualifier auto 79 cp0 77 mips16e 78 mips32r2 78 near 76 persistent 31 76 sfr 77 strictcall 78 volatile 116 INDEX INDEX qualifiers 75 76 and auto variables 79 const 75 pointer 78 volatile 75 quiet mode 48 radix specifiers assembly 116 binary 67 C source 67 decimal 67 hexadecimal 67 octal 67 rand function 239 rbit psect 86 rbss psect 87 rdata psect 29 read only variables 75 recursion 65 redirecting errors 43 reference 140 149 regsused pragma directive 101 RELOC 142 144 reloc PSECT flag 124 relocatable object files 137 relocation 137 relocation information preserving 144 REPT directive 130 reserving memory 59 reset code executed after 33 reset psect 86 return values 81 rotate operation 65 round function 241 runtime environment 60 RUNTIME option clear 60 clib 60 init 60 keep 60 no_startup 60 runtime startup variable initialization 29 runtime startup code 28 runtime startup module 26 60 scale value 123 scanf function 242 search path header files 44 segment selector 142 segments see psects 142 149 serial I O 107 serial numbers 61 174 accessing 61 SET directive 114 126 set
127. 4 174 3c C 0 aldiv obj text 90 90 3C C 0 indicates that both the ilaldiv ob3 and aldiv obj modules were linked in from the library file pic861 c lib Underneath the library file contributions there may be a label COMMON This shows the con tribution to the program from program wide psects in particular that used by the compiled stack auto parameter area This information in this section of the map file can be used to observe several details e To confirm that a module is making a contribution to the output file by ensuring that the module appears in the module list e To determine the exact psects that each module defines 152 Linker and Utilities Map Files e For cases where a user defined routine with the same name as a library routine is present in the programs source file list to confirm that the user defined routine was linked in preference to the library routine 5 9 2 3 Psect Information listed by Class The next section in the map file is the same psect information listed by module but this time grouped into the psects class This section is heralded by the line that contains the headings TOTAL Name Link Load Length Under this are the class names followed by those psects which belong to this class These psects are the same as those listed by module in the above section there is no new information contained in this section 5 9 2 4 Segment Listing The class listing in the map file is followed by a listing
128. 4 The printf Routine The code associated with the printf function is not found in the library files The printf function is generated from a special C source file that is customized after analysis of the user s C code See Section for more information on the printf library function This template file is found in the LIB directory of the compiler distribution and is called doprnt c It contains a minimal implementation of the printf function but with the more advanced features included as conditional code which can be utilized via preprocessor macros that are defined when it is compiled The parser and code generator analyze the C source code searching for calls to the print f func tion For all calls the placeholders that were specified in the printf format strings are collated to produce a list of the desired functionality of the final function The doprnt c file is then prepro cessed with the those macros specified by the preliminary analysis thus creating a custom printf 33 Runtime Files PICC32 Command line Driver function for the project being compiled After parsing the p code output derived from doprnt c is then combined with the remainder of the C program in the final code generation step TUTORIAL CALLS TO PRINTF A program contains one call to printf which looks like printf input is d The compiler will note that only the d placeholder is used and the doprnt module that is linked into the program will only
129. AL ADDING AND DELETING DEFAULT LINKER OPTIONS The default linker options for 46 PICC32 Command line Driver PICC32 Driver Option Descriptions for a project links several psects in the following fashion pone 600h two three which links one at 600h then follows this with two then three It has been decided that the psects should be linked so that one follows two which follows three and that the highest address of one should be located at 5FFh This new arragement can be specified issuing the following driver option L pthree 600h two one which creates passes the required linker options to the linker The existing default option is still present so this must be removed by use the driver option L pone which will remove the existing option The default option that you are deleting or replacing must contain an equal character 2 6 8 Mfile Generate Map File The M option is used to request the generation of a map file The map is generated by the linker an includes detailed information about where objects are located in memory see Section 5 9 for information regarding the content of map files If no filename is specified with the option then the name of the map file will have the project name with the extension map 2 6 9 Nsize Identifier Length This option allows the C identifier length to be increased from the default value of 31 Valid sizes for this option are from 32 to 255 The option has no effect f
130. EATIES o o o o e oca ae ee a E o 158 3 10 7 Efor Messages os k coru A A E a a ae eas 158 ODON E za as eo hoe ee A Be eS Beh ee E eS 158 SAT Checksum Specmitations s o 4064 64 he eeu ee EER Se e Ss 158 CS 66 eka ge tas 455 2 Bree a se Eee hee hea tae amp oe lig 160 SAAT 0 cc cades Ae ee be eae PLE ER EASE GA Ee 160 3122 HMhedding prg s e i AE eS ESE ee AO e as 161 DAZ Het owe alee a he eke bale Se eel Cee ee Bw a ee eS 161 IMA OGUE curia ig SR a pO A RES Ba ae ee eS 161 DAG AR Be a a Be ee ee i ae oO Sh 161 ALO OSO PIS oe AR ER EAR a OS 161 IEE 1 A A A be Som Bek 162 Cromwell o sies ar a rd o Ge ek ee ee 162 3 13 1 lt Pnamel architecture o oec a ia ea ee eA eR AR Ewe a 163 SAG ON oe ee ee ER ae ee Ca ae Bae a eee 163 IS A a Sg BR A po eG Ba BB Ba ae Ba a 163 cMr O 164 NBS SP x spe Sa E Ae ee eS EA Re Boe ee eS 164 SO URSS 532000 e Gide As es te ote ba dos E A 164 Na NA 164 SBS rs e A a BASE eS RAE a 164 A E he ee Ca ae aw a ee eS 165 ENE se cutee ope ok ig Gee a po RG Ba RB BA a ek RE 165 SASM o oe eH Bh ee 2 he ee Bh Ee ae 4 eS 165 MARN o coe a eS A Soe eA RE ee A ee eS 165 HSA das o aw BAe aby sa A eR EB He amp A 165 5 14 1 Hexmate Command Line Options 0 166 5 14 1 1 specifications filename hex 00 166 SAAD EPIA oe no a a ee oe a Ewe Saw ee a 168 314 13 ADDRESSING goku oS a GS ee ae 168 3 14 14 lt BREAR eere crete akuweke ee ee ee ee 169 SIGS CR pik cee ae be One Ale eA A eee BRS
131. ELL FOMMALTY PES So back bw bbe A A a e ue aE eee 162 CROMWELL Command line Options se ecne spess esas EE Re 163 P option architecture arguments for COFF file output 164 Hexmate command line options ee ee ee eS 167 Hexmate Checksum Algorithm Selection o e 170 INHX types used in FORMAT option o o o 173 Devices supported by HI TECH C PRO for the PIC32 MCU Family 415 Chapter 1 Introduction 1 1 Typographic conventions Different fonts and styles are used throughout this manual to indicate special words or text Com puter prompts responses and filenames will be printed in constant spaced type When the filename is the name of a standard header file the name will be enclosed in angle brackets e g lt stdio h gt These header files can be found in the INCLUDE directory of your distribution Samples of code C keywords or types assembler instructions and labels will also be printed in a constant space type Assembler code is printed in a font similar to that used by C code Particularly useful points and new terms will be emphasized using italicized type When part of a term requires substitution that part should be printed in the appropriate font but in italics For example include lt filename h gt Typographic conventions Introduction 18 Chapter 2 PICC32 Command line Driver PICC32_ is the driver invoked from the command line to perform all aspects of
132. F If an English message string is not present a message similar to error warning generated but no description available where indicates the message number that was generated will be printed otherwise the message in the requested language will be displayed 2 5 2 Message Language HI TECH C PRO for the PIC32 MCU Family Supports more than one language for displayed mes sages There is one MDF for each language supported The language used for messaging may be specified with each compile using the LANG option see Section 2 6 33 Alternatively it may be set up in a more permanent manner by using the LANG option together with the SETUP option which will store the default language in either the reg istry under Windows or in a configuration file on other systems On subsequent builds the default language used will be that specified Table shows the MDF applicable for the currently supported languages 2 5 3 Message Type There are four types of message whose default behaviour is described below Advisory Messages convey information regarding a situation the compiler has encountered or some action the compiler is about to take The information is being displayed for your interest and typically require no action to be taken Unless prevented by some driver option or another error message the project will be linked and the requested output file s will be generated Warning Messages indicate source code or some other s
133. I TECH C Assembly Language When invoking a macro the argument list must be comma separated If it is desired to include a comma or other delimiter such as a space in an argument then angle brackets lt and gt may be used to quote the argument In addition the exclamation mark may be used to quote a single character The character immediately following the exclamation mark will be passed into the macro argument even if it is normally a comment indicator If an argument is preceded by a percent sign that argument will be evaluated as an expression and passed as a decimal number rather than as a string This is useful if evaluation of the argument inside the macro body would yield a different result The nul operator may be used within a macro to test a macro argument for example IF nul arg3 argument was not supplied ELSE argument was supplied ENDIF By default the assembly list file will show macro in an unexpanded format i e as the macro was invoked Expansion of the macro in the listing file can be shown by using the EXPAND assembler control see Section 4 3 11 7 43 10 16 LOCAL The LOCAL directive allows unique labels to be defined for each expansion of a given macro Any symbols listed after the LOCAL directive will have a unique assembler generated symbol substituted for them when the macro is expanded For example down MACRO count LOCAL more more decfsz count goto more ENDM when expanded will include a
134. I TECH Software technical support with details 607 inconsistent line number tables Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 608 bad path specification Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 609 missing processor spec after P Cromwell The p option to cromwell must specify a processor name 610 missing psect classes after N Cromwell Cromwell requires that the N option be given a list of the names of psect classes 611 too many input files Cromwell To many input files have been specified to be converted by CROMWELL 612 too many output files Cromwell To many output file formats have been specified to CROMWELL 613 no output file format specified Cromwell The output format must be specified to CROMWELL 614 no input files specified Cromwell CROMWELL must have an input file to convert 616 option Cbaseaddr is illegal with options R or L Linker The linker option Cbaseaddr cannot be used in conjunction with either the R or L linker options 362 Error and Warning Messages 618 error reading COD file data Cromwell An error occurred reading the input COD file Confirm the spelling and path of the file specified on the command line 619 T O error reading symbol table Cromwell The COD file has an invalid format in the specified record 62
135. LES AND SOURCE FILES A C source file is a file on disk that contains all or part of a program C source files are initially passed to the preprocessor by the driver A module is the output of the preprocessor for a given source file after inclusion of any header files or other source files which are specified by include preprocessor 20 PICC32 Command line Driver Invoking the Compiler directives These modules are then passed to the remainder of the compiler applications Thus a module may consist of several source and header files A module is also often referred to as a translation unit These terms can also be applied to assembly files as they too can include other header and source files Some of the compiler s output files contain project wide information and are not directly associated with any one particular input file e g the map file If the names of these project wide files are not specified on the command line the basename of these files is derived from the first C source file listed on the command line If there are no files of this type being compiled the name is based on the first input file regardless of type on the command line Throughout this manual the basename of this file will be called the project name Most IDEs use project files whose names are user specified Typically the names of project wide files such as map files are named after the project however check the manual for the IDE you are using for mo
136. Library Functions DIV Synopsis include lt stdlib h gt div_t div int numer int demon Description The div function computes the quotient and remainder of the numerator divided by the denomina tor Example include lt stdlib h gt include lt stdio h gt void main void div_t x x div 12345 66 printf quotient d remainder d n x quot x rem See Also udiv IdivO uldiv Return Value Returns the quotient and remainder into the div_t structure 199 Library Functions EVAL_POLY Synopsis include lt math h gt double eval_poly double x const double d int n Description The eval_poly function evaluates a polynomial whose coefficients are contained in the array d at x for example y x x d2 x dl d0 The order of the polynomial is passed in n Example include lt stdio h gt include lt math h gt void main void double x y double d 3 1 1 3 5 2 7 x 2 2 y eval_poly x d 2 printf The polynomial evaluated at f is f n x y Return Value A double value being the polynomial evaluated at x 200 Library Functions EXP Synopsis include lt math h gt double exp double f Description The exp routine returns the exponential function of its argument i e e to the power of f Example include lt math h gt include lt stdio h gt void main void double f for f 0 0
137. Meaning C C source file pl p code file lpp p code library file as Assembler source file 0b3 Relocatable object code file Lib Relocatable object library file hex Intel HEX file 2 1 Invoking the Compiler This chapter looks at how to use PICC32 as well as the tasks that it and the internal applications perform during compilation PICC32 has the following basic command format PICC32 options files libraries It is conventional to supply opt ions identified by a leading dash or double dash before the filenames although this is not mandatory The formats of the options are discussed below in Section 2 6 and a detailed description of each option follows The files may be any mixture of C and assembler source files and precompiled intermediate files such as relocatable object obj files or p code p1 files The order of the files is not important except that it may affect the order in which code or data appears in memory and may affect the name of some of the output files Libraries is a list of either object code or p code library files that will be searched by the linker PICC32 distinguishes source files intermediate files and library files solely by the file type or extension Recognized file types are listed in Table 2 1 This means for example that an assembler file must always have a as extension Alphabetic case of the extension is not important from the compiler s point of view MODU
138. NHX032 is not an actual INHX format Selection of this type generates an INHX32 file but will also initialize the upper address information to zero This is a requirement of some device programmers 5 14 1 11 HELP Using HELP will list all hexmate options By entering another hexmate option as a parameter of HELP will show a detailed help message for the given option For example HELP string will show additional help for the STRING hexmate option 5 14 1 12 LOGFILE The LOGFILE option saves hex file statistics to the named file For example LOGFILE output log will analyse the hex file that hexmate is generating and save a report to a file named output log 173 Hexmate Linker and Utilities 5 14 1 13 MASK Use this option to logically AND a memory range with a particular bitmask This is used to ensure that the unimplemented bits in program words if any are left blank The usage of this option is as follows MASK hexcodelstart end Where hexcode is a hexadecimal value that will be ANDed with data within the start end address range Multibyte mask values can be entered in little endian byte order 5 14 1 14 Ofile The generated Intel hex output will be created in this file For example Oprogram hex will save the resultant output to program hex The output file can take the same name as one of its input files but by doing so it will replace the input file entirely 5 14 1 15 SERIAL This option will store
139. RAM area is invalid TRUE non zero if the NVRAM area is valid 231 Library Functions POW Synopsis include lt math h gt double pow double f double p Description The pow function raises its first argument f to the power p Example include lt math h gt include lt stdio h gt void main void double f for f 1 0 lt 10 0 f 1 0 printf pow 2 1 0f f n f pow 2 f See Also logQ log100 expO Return Value f to the power of p 232 Library Functions PUTCH Synopsis include lt conio h gt void putch char c Description The putch function outputs the character e to the console screen prepending a carriage return if the character is a newline In a CP M or MS DOS system this will use one of the system I O calls In an embedded system this routine and associated others will be defined in a hardware dependent way The standard putch routines in the embedded library interface either to a serial port or to the Lucifer Debugger Example include lt conio h gt char x This is a string void main void char cp Cp X while x putch xt putch n See Also cgets cputs getch getche 233 Library Functions PUTCHAR Synopsis include lt stdio h gt int putchar int c Description The putchar function is a putc operation on stdout defined in stdio h Example include lt s
140. S 0 E T w A R E HI TECH C Tools for the oce PIC32 MCU Family HI TECH C TOOLS for the PIC32 MCU Family HI TECH Software Copyright C 2008 HI TECH Software All Rights Reserved Printed in Australia Produced on July 22 2008 HI TECH Software Pty Ltd ACN 002 724 549 45 Colebard Street West Acacia Ridge QLD 4110 Australia email hitech htsoft com web http microchip htsoft com ftp ftp www htsoft com Contents Table of Contents List of Tables 1 Introduction 1 1 Typographic conventions s lt 6 ee ee ee a 2 PICC32 Command line Driver 2 1 Invoking the Compiler ociosos bead e a ee 211 Long Command Lines sirios 8 esrb ew ha dhe tens 22 Vhescomprlation Sequence 2 ca hoe ee RS OER RO e eS 224 Smele step Compilaton lt i 22 4 6 8e chee hs HRM EES A ore amp oe eS 222 Generating Intermediate Files s poeg serie 2243 Special Processiig eo e en ERE SSAA SE EASES beh Pal a 3 4 6 5 4 os Slee oR ee ew Gees 2 2 3 2 Assembly Code Requirements Zod MUNI FIES Loja OR a EAR ES eR Ee ES 234 Library Pues e oe ae a de ee Bh bead REE 2 3 1 1 Standard Libraries oos o cos ra ek e Ss 2 3 2 Peripheral Labranes cuco 54 BGR Ae e aS 23 2 Runtime Startup Mod le s s se kk ee aa a 2 3 2 1 Initialization of Data psects o 2302 leanne ihe Bss Psect o on soa dr eee do eS 2 3 2 3 System Coprocessor Initialization RUNTIME cp0 2 3 2 4 General Purpos
141. SS1 Compile to P code PRE Produce preprocessed source files PROTO Generate function prototype information RAM 1l0 hi lt lo hi gt Specify and or reserve RAM ranges ROM 1l0 hi lt lo hi gt Specify and or reserve ROM ranges RUNTIME t ype Configure the C runtime libraries to the specified type SCANDEP Generate file dependency DEP files SETOPTION app file Set the command line options for the named applica tion STRICT Enable strict ANSI keyword conformance STRICTCALLS Strict MIPS parameter passing SUMMARY t ype Selects the type of memory summary output TIME Report time taken for each phase of build process VER Display the compiler s version number WARN level Set the compiler s warning level WARNFORMAT format Format warning message strings to given style
142. T 38 HTC_WARN_FORMAT 38 VO console I O functions 107 serial 107 STDIO 107 idata psect 29 60 86 identifier length 47 identifiers assembly 117 IEEE floating point format 72 IF directive 127 Implementation defined behaviour 65 division and modulus 85 shifts 84 428 in line assembly 93 INCLUDE assembler control 133 include files assembly 133 incremental builds 24 INHX32 165 172 INHX8M 165 173 init psect 86 initialization of variables 29 input files 20 int data types 71 integer suffix long 69 unsigned 69 integral constants 69 integral promotion 83 Intermediate files 57 intermediate files 20 24 55 interrupt functions 87 context saving 101 interrupt keyword 87 interrupts handling in C 87 IRP directive 130 IRPC directive 130 isa qualifier 78 isalnum function 212 isalpha function 212 isatty function 214 isdigit function 212 islower function 212 itoa function 215 Japanese character handling 100 JIS character handling 100 jis pragma directive 100 kbhit function 107 keyword INDEX INDEX auto 79 excluding 60 cp0 77 format of 155 extern 91 linking 147 interrupt 87 listing modules in 156 ISA 78 module order 158 near 76 naming convention 28 persistent 31 76 scanning additional 45 str 77 used in executable 144 strictcall 78 library keywords difference between object file 155 disabling non ANSI 62 l obj output file 23 label field 114
143. The code generator has been passed a pragma directive that it does not understand This implies that the pragma you have used is a HI TECH specific pragma but the specific compiler you are using has not implemented this pragma 368 Error and Warning Messages 716 bad argument to M option Code Generator The code generator has been passed a M option that it does not understand This should not happen if it is being invoked by a standard compiler driver 718 incompatible intermediate code version should be Code Generator The intermediate code file produced by P1 is not the correct version for use with this code generator This is either that incompatible versions of one or more compilers have been installed in the same directory or a temporary file error has occurred leading to corruption of a temporary file Check the setting of the TEMP environment variable If it refers to a long path name change it to something shorter Contact HI TECH Support with details if required 720 multiple free Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 721 element count must be constant expression Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 722 bad variable syntax in intermediate code Code Generator This is an internal compiler error Contact HI TECH Software technical support with details
144. The strespn function returns the length of the initial segment of the string pointed to by s1 which consists of characters NOT from the string pointed to by s2 Example include lt stdio h gt include lt string h gt void main void static char set xyz printf Sd n strespn abcdevwxyz set printf Sd n strespn xxxbcadefs set printf Sd n strespn 1234567890 set See Also strspn Return Value Returns the length of the segment 256 Library Functions STRLEN Synopsis include lt string h gt size_t strlen const char s Description The strlen function returns the number of characters in the string s not including the null termina tor Example include lt string h gt include lt stdio h gt void main void char buffer 256 chars si 27 strcpy buffer Start of line sl buffer s2 end of line strcat s1 s2 printf Length d n strlen buffer printf string s n buffer Return Value The number of characters preceding the null terminator 257 Library Functions STRNCAT Synopsis include lt string h gt char strncat char sl const char s2 size_t n Description This function appends concatenates string s2 to the end of string s1 At most n characters will be copied and the result will be null terminated s1 must point to a character array big enough to hold
145. This is an internal compiler error Contact HI TECH Software technical support with details 419 object file is not absolute Objtohex The object file passed to OBJTOHEX has relocation items in it This may indicate it is the wrong object file or that the linker or OBJTOHEX have been given invalid options The object output files from the assembler are relocatable not absolute The object file output of the linker is absolute 420 too many relocation items Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 421 too many segments Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 422 noend record Linker This object file has no end record This probably means it is not an object file Contact HI TECH Support if the object file was generated by the compiler 423 illegal record type Linker There is an error in an object file This is either an invalid object file or an internal error in the linker Contact HI TECH Support with details if the object file was created by the compiler 424 record too long Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 425 incomplete record Objtohex Libr The object file passed to OBJTOHEX or the librarian is corrupted Contact HI TECH Support with details 427 syntax error in checksum list Objtohex There is a syntax error in
146. _vector function 246 setjmp function 244 sfr qualifier 77 shift operations result of 84 sign extension when shifting 84 SIGNAT directive 91 106 131 signature checking 105 signature values 89 signatures 132 sin function 247 single step compilation 23 sinh function 196 size PSECT flag 124 skipping applications 62 source file 20 SPACE assembler control 135 space PSECT flag 124 435 INDEX INDEX special characters in assembly 114 special function registers 94 special type qualifiers 76 sports cars 118 sqrt function 248 srand function 249 stack usage 60 stack frame 82 standard library files 27 28 standard type qualifiers 75 startup module 60 clearing bss 138 data copying 139 startup as 29 static variables 79 STDIO 107 storage class 79 strcat function 250 strchr function 251 strcmp function 253 strcpy function 255 strespn function 256 strichr function 251 stricmp function 253 strictcall qualifier 78 string literals 69 175 concatenation 69 String packing 176 strings assembly 117 storage location 69 175 type of 69 stristr function 267 strlen function 257 strncat function 258 strncmp function 260 strncpy function 262 strnicmp function 260 436 strpbrk function 264 strrchr function 265 strrichr function 265 strspn function 266 strstr function 267 strtod function 268 strtok function 272 strtol function 270 structures bit fields 73 qualifi
147. a RE SO a GO ee eae 127 G43 0013 DABS is 6 23 45 De e a Bae a RAS BS 127 4 3 10 14 IF ELSIF ELSE and ENDIF 0 127 43 10 15 MACRO and ENDM css rs OR OO 128 CONTENTS CONTENTS 4 3 11 5 Linker and Utilities 5 1 Introduction 5 2 Relocation and Psects 5 3 Program Sections 5 4 Local Psects 5 5 Global Symbols 5 6 Link and load addresses 5 7 Operation Ird Phe JS 5 7 4 IO 4 3 10 16 LOCAL 4 3 10 17 ALIGN 4 3 10 18 REPT 4 3 10 19 IRP and IRPC 4 3 10 20 PROCESSOR 4 3 10 21 SIGNAT Assembler Controls ASMOPT_ON ASMOPT_OFF FORCE_EXTEND NEVER_EXTEND AUTO_EXTEND 4 3 11 10 NOCOND 4 3 11 11 NOEXPAND 4 3 11 12 NOLIST 4 3 11 13 NOXREF 4 3 11 14 PAGE 4 3 11 15 SPACE 4 3 11 16 SUBTITLE 4 3 11 17 TITLE 4 3 11 18 XREF Numbers in linker options Aclass low high CONTENTS CONTENTS 10 5 8 5 9 ShO Doyle oers nera breede a ea eR ee Dee De 142 Il A a bok de sk eR aL gis Bow eA BOR Ag a ee A eB e S 142 DS Pes BO ed e ee ES SR eS 142 SD A co ee E RE Re eR Ge OES A ee eS 142 Soh SE DA kw eh a Re ye Ee Slee ee amp BALE GAAS DS 143 DAL ESTE oe hk abe bh bee ee we ee eee eA 143 INA 1 opa u hk te hip et Bh God Se ows eke tip Ae ee Bp a aoe RS 143 Dede Ko 4405 Ge E A Se ea a ae amp 143 Ilp aal A A a a R a e a S 144 S eai e Wed a Bb ee ted Aue be Se SS i ee RA 144 SG SEM oe ne ke ee EE AP Be Boe Oe A EA eS 144 Sle ERNUS Sra EM ee hee Se aD a Be Hd 144 IRE SI Neamd dn E els dow de p eek Gadi
148. a class of psects linked into more than one non contiguous address range This option allows a number of address ranges to be specified for a class For example ACODE 1020h 7FFEh 8000h BFFEh specifies that the class CODE is to be linked into the given address ranges Note that a contribution to a psect from one module cannot be split but the linker will attempt to pack each block from each module into the address ranges starting with the first specified Where there are a number of identical contiguous address ranges they may be specified with a repeat count e g ACODE 0 FFFFhx16 specifies that there are 16 contiguous ranges each 64k bytes in size starting from zero Even though the ranges are contiguous no code will straddle a 64k boundary The repeat count is specified as the character x or after a range followed by a count 5 7 3 Cx These options allow control over the call graph information which may be included in the map file produced by the linker There are four varients of this option Fully expanded callgraph The Cf option displays the full callgraph information Short form callgraph The Cs option is the default callgraph option which removes some redun dant information from the callgraph display In the case where there are parameters to a function that involve function calls the callgraph information associated with the ARG func tion is only shown the first time it is encountered in the callgraph See S
149. a constant of type int e g enum one 1 two about_three 3 12 no non int values allowed 992 can t find op Assembler Optimiser This is an internal compiler error Contact HI TECH Software technical support with details 993 some command line options are disabled Driver The compiler is operating in demo mode Some command line options are disabled 994 some command line options are disabled and compilation is delayed Driver The compiler is operating in demo mode Some command line options are disabled the compilation speed will be slower 397 Error and Warning Messages 995 some command line options are disabled code size is limited to 16kB compilation is delayed Driver The compiler is operating in demo mode Some command line options are disabled the compilation speed will be slower and the maximum allowed code size is limited to 16kB 1015 missing specification in chipinfo file at line Driver This attribute was expected to appear at least once but was not defined for this chip 1016 missing argument to specification in chipinfo file at line Driver This value of this attribute is blank in the chip configuration file 1017 extraneous argument to specification in chipinfo file at line Driver There are too many attributes for the the listed specification in the chip configuration file 1018 illegal number of specification
150. a hook to the reset vector provided via the powerup routine This routine can be supplied in a user defined assembler module that will be executed immedi ately after reset An empty powerup routine is provided in the file powerup as which is located in the SOURCES directory of your compiler distribution Refer to comments in this file for more details The file should be copied to your working directory modified and included into your project as a source file No special linker options or other code is required the compiler will detect if you have defined a powerup routine and will automatically use it provided the code in this routine is contained in a psect called powerup The runtime startup code will invoke the powerup routine using a absolute jump and link instruc tion which will place the return address in register 31 ra For correct operation when using the default compiler generated runtime startup code the code must contain at its end a jr ra instruc tion and ensure that it preserves the address in register 31 As with all user defined assembly code it must take into consideration program memory paging and or data memory banking as well as any applicable errata issues for the device you are using The program s entry point is already defined by the runtime startup code so this should not be specified in the powerup routine at the END directive if used See Section 4 3 10 2 for more information on this assembler directive 2 3
151. a label 194 expected Parser A closing parenthesis was expected here This may indicate you have left out this character in an expression or you have some other syntax error The error is flagged on the line at which the code first starts to make no sense This may be a statement following the incomplete expression e g if a b the closing parenthesis is missing here b 0 the error is flagged here 195 expression syntax Parser This expression is badly formed and cannot be parsed by the compiler e g a b oops maybe that should be a b 303 Error and Warning Messages 196 struct union required Parser A structure or union identifier is required before a dot e g int a a b 9 oops a is not a structure 197 struct union member expected Parser wou A structure or union member name must follow a dot or arrow gt 198 undefined struct union Parser The specified structure or union tag is undefined e g struct WHAT what a definition for WHAT was never seen 199 logical type required Parser The expression used as an operand to if while statements or to boolean operators like and amp amp must be a scalar integral type e g struct FORMAT format if format this operand must be a scaler type format a 0 200 taking the address of a register variable is illegal Parser A variable declared regis
152. a particular hex value at a fixed address The usage of this option is SERIAL Code Increment Address Interval rRepetitions where e Code is a hexadecimal value to store and is entered in little endian byte order e Increment is optional and allows the value of Code to change by this value with each repetition if requested e Address is the location to store this code or the first repetition thereof e Interval is optional and specifies the address shift per repetition of this code e Repetitions is optional and specifies the number of times to repeat this code For example SERIAL 000001 EFFE 174 Linker and Utilities Hexmate will store hex code 00001h to address EFFEh Another example SERIAL 0000 2 1000 10r5 will store 5 codes beginning with value 0000 at address 1000h Subsequent codes will appear at address intervals of 10h and the code value will change in increments of 2h 5 14 1 16 SIZE Using the SIZE option will report the number of bytes of data within the resultant hex image to standard output The size will also be recorded in the log file if one has been requested 5 14 1 17 STRING The STRING option will embed an ASCII string at a fixed address The usage of this option is STRING Address tCode Text where e Address is the location to store this string e Code is optional and allows a byte sequence to trail each byte in the string This can allow the bytes of the string to b
153. a symbol is used in more than one context The instruction and addressing mode syntax provide all the information necessary for the assembler to generate correct code 4 3 7 2 Assembler Generated Identifiers Where a LOCAL directive is used in a macro block the assembler will generate a unique symbol to replace each specified identifier in each expansion of that macro These unique symbols will have the form nnnn where nnnn is a 4 digit number The user should avoid defining symbols with the same form 4 3 7 3 Symbolic Labels A label is symbolic alias which is assigned a value equal to its offset within the current psect A label definition consists of any valid assembly identifier followed by a colon The defini tion may appear on a line by itself or be positioned before a statement Here are two examples of legitimate labels interspersed with assembly code frank ori a3 zero 16 J fin simon44 sb zero _input __gptr gp Here the label frank will ultimately be assigned the address of the ori instruction and simon44 the address of the sb instruction Regardless of how they are defined the assembler list file produced by the assembler will always show labels on a line by themselves Labels may be used and are prefered in assembly code rather than using an absolute address Thus they can be used as the target location for jump type instructions or to load an address into a register Like variables labels have scope By defaul
154. aS es 69 3 3 3 Using Bit Addressable Registers oaaae 70 3 3 4 8 Bit Integer Data Types and Variables 71 3 35 16 Bit Inteper Data Types o ccce sarea kuntaa Eudha e eS 71 3 3 6 32 Bit Integer Data Types and Variables 72 3 3 7 Floating Point Types and Variables o 72 2 2 8 Stiucturesand Umions lt lt pus es ER ROS EHR ERA Re eS 73 S001 Bit felds im SUCES e oe oe ewe oe eee Se Rh LES oS 73 3 3 8 2 Structure and Union Qualifiers 04 74 3 3 9 Standard Type Qualifiers sso saes ee ee eR oa a 75 3 3 9 1 Constand Volatile Type Qualifiers 75 3 33 10 Special Type Qualifiers oo a a A 76 331041 Persistent Type Qualifier ico e 4 4444 76 IOMA EPO Type QUA TES o e E A AA es 77 S53 108 sit Type QUEEN a a oo oe wee ete amp wh LBS oS 77 3 3 10 4 _ strictcall Function Qualifier 78 3 3 10 5 ISA Function Qualifiers ae 78 Sell Pomter Types ce coo ira a e 78 SS Lal Pointers to CONS sor pusana o e a RB Bh a E 78 3 3 11 2 Function Pointers 1 2 6 56 corso eee eee we 79 3 4 Storage Class and Object Placement gt s s oos eeu o o 79 tl Local Variables co bpess rra AA e WS 79 ILL Auto Vamables lt lt ptas ar dr or ee es 79 34 1 2 Static Variables o c ceo con ee a eS eS 79 342 Absolute Variables o ces 24 5 Ge ae bee a a ae 80 343 Objects Program Space sao
155. able 3 9 Valid register names Register Name Description wreg W register status STATUS register pclat PCLATH register prodl prodh product result registers fsrO fsrl fsr2 indirect data pointers 0 1 and 2 tblptrl tblptrh tblptru table pointer registers Table 3 10 Switch types switch type description auto use smallest code size method default direct table lookup fixed delay pragma switch switch_type where switch_type is one of the available switch methods listed in Table Specifying the direct option to the pragma switch directive forces the compiler to generate the table look up style switch method This is mostly useful where timing is an issue for switch statements 1 e state machines This pragma affects all code generated onward The auto option may be used to revert to the default behaviour 3 11 4 5 The pragma warning Directive The warning disable pragma Some warning messages can be disabled by using the warning disable pragma This pragma will only affect warnings that are produced by either parser or the code generator i e errors directly associated with C code The position of the pragma is only significant for the parser i e a parser warning number may be disabled then re enabled around a section of the code to target specific instances of the warning Specific instances of a warning produced by the code generator cannot be individually controlled T
156. acter inside the single quotes is missing e g char c the character value of what 226 char const too long Parser A character constant enclosed in single quotes may not contain more than one character e g c 12 oops only one character may be specified 227 expected after Parser The only context in which two successive dots may appear is as part of the ellipsis symbol which must have 3 dots An ellipsis is used in function prototypes to indicate a variable number of param eters Either was meant to be an ellipsis symbol which would require you to add an extra dot or it was meant to be a structure member operator which would require you remove one dot 228 illegal character 0x Parser This character is illegal in the C code Valid characters are the letters digits and those comprising the acceptable operators e g c a oops did you mean c a 229 unknown qualifier given to A Parser This is an internal compiler error Contact HI TECH Software technical support with details 230 missing argument to A Parser This is an internal compiler error Contact HI TECH Software technical support with details 309 Error and Warning Messages 231 unknown qualifier given to I Parser This is an internal compiler error Contact HI TECH Software technical support with details 232 missing argument to I Parser This is
157. ader for the selected chip 3 3 4 8 Bit Integer Data Types and Variables HI TECH C PRO for the PIC32 MCU Family supports both signed char and unsigned char 8 bit integral types If the signed or unsigned keyword is absent from the variable s definition the default type is unsigned char The signed char type is an 8 bit two s complement signed integer type representing integral values from 128 to 127 inclusive The unsigned char is an 8 bit unsigned integer type representing integral values from 0 to 255 inclusive It is a common misconception that the C char types are intended purely for ASCII character manipulation This is not true indeed the C language makes no guarantee that the default character representation is even ASCII The char types are simply the smallest of up to four possible integer sizes and behave in all respects like integers The reason for the name char is historical and does not mean that char can only be used to represent characters It is possible to freely mix char values with short int and long values in C expressions With HI TECH C PRO for the PIC32 MCU Family the char types will commonly be used for a number of purposes as 8 bit integers as storage for ASCII characters and for access to T O locations Variables may be declared using the signed char and unsigned char keywords respectively to hold values of these types Where only char is used in the declaration the type will be signed char unless the
158. advantage of it s separate set clear and toggle addresses Only 4 byte unsigned integer data type variables may be qualified as sfr Structures or unions so qualified may only have members which are bitfields or structures or unions which only have bitfield members For example the SFR WDTCON from the device specific header file 32mx360 5121 h is as follows volatile sfr unsigned long WDTCON 0xBF800000 typedef union struct unsigned volatile WDTCLR 1 unsigned 1 unsigned volatile SWDTPS0 1 unsigned volatile SWDTPS1 1 unsigned volatile SWDTPS2 1 unsigned volatile SWDTPS3 1 unsigned volatile SWDTPS4 1 unsigned 8 unsigned volatile ON 1 y struct unsigned 2 unsigned volatile WDTPSTA 5 y struct unsigned volatile w 32 i __WDTCONbits_t volatile _ WDTCONbits_t sfr WDICONbits 0xBF800000 77 Supported Data Types and Variables C Language Features 3 3 10 4 _ strictcall Function Qualifier If the __ strictcall qualifier is used only the first 4 a registers are used for passing parameters to this function If the __ st rictca1J qualifier is not used the HI TECH C PRO for the PIC32 MCU Family will dynamically determine which registers to use for passing parameters for that function 3 3 10 5 ISA Function Qualifiers Use of one of the mips16e or mips32r2 qualifiers may be used to explicitly generate a function in the particular ISA Note that these qualifiers will override the
159. agma pack Parser The pragma pack requires a decimal number as argument This specifies the alignment of each member within the structure Use this with caution as some processors enforce alignment and will not operate correctly if word fetches are made on odd boundaries e g pragma pack what is the alignment value Maybe you meant something like pragma pack 2 215 missing argument to pragma switch Parser The pragma switch requires an argument of auto direct or simple e g pragma switch oops this requires a switch mode maybe you meant something like pragma switch simple 216 missing argument to pragma psect Parser The pragma psect requires an argument of the form ol dname newname where oldname is an existing psect name known to the compiler and newname is the desired new name e g pragma psect oops this requires an psect to redirect maybe you meant something like pragma psect text specialtext 218 missing name after pragma inline Parser The inline pragma expects the name of a function to follow The function name must be recognized by the code generator for it to be expanded other functions are not altered e g pragma inline what is the function name maybe you meant something like pragma inline memcpy 307 Error and Warning Messages 219 missing name after pragma printf_check Parser The printf_check pragma expects the name of a function to
160. alised to the value 1 and the other is not initialised The first will be placed into the data psect and the second in the bss psect The bss psect is always cleared to zeros on startup of the program thus the second variable will be initialised at run time to zero The first will however occupy space in the program file and will maintain its initialised value of 1 at startup It is quite possible to modify the value of a variable in the data psect during execution however it is better practice not to do so since this leads to more consistent use of variables and allows for restartable and ROMable programs For more information on the particular psects used in a specific compiler refer to the appropriate machine specific chapter 5 4 Local Psects Most psects are global i e they are referred to by the same name in all modules and any reference in any module to a global psect will refer to the same psect as any other reference Some psects are local which means that they are local to only one module and will be considered as separate from any other psect even of the same name in another module Local psects can only be referred to at link time by a class name which is a name associated with one or more psects via the PSECT directive class in assembler code See Section 4 3 10 3 for more information on PSECT options 5 5 Global Symbols The linker handles only symbols which have been declared as GLOBAL to the assembler The code generator
161. ally followed by an assign ment suppression character optionally followed by a numerical maximum field width followed by a conversion specification character Each conversion specification unless it incorporates the as signment suppression character will assign a value to the variable pointed at by the next argument Thus if there are two conversion specifications in the fmt string there should be two additional pointer arguments The conversion characters are as follows oxd Skip white space then convert a number in base 8 16 or 10 radix respectively If a field width was supplied take at most that many characters from the input A leading minus sign will be recognized s Skip white space then copy a maximal length sequence of non white space characters The pointer argument must be a pointer to char The field width will limit the number of characters copied The resultant string will be null terminated c Copy the next character from the input The pointer argument is assumed to be a pointer to char If a 242 Library Functions field width is specified then copy that many characters This differs from the s format in that white space does not terminate the character sequence The conversion characters 0 x u and d may be preceded by an l to indicate that the correspond ing pointer argument is a pointer to long as appropriate A preceding h will indicate that the pointer argument is a pointer to short rather than i
162. alues overflowing For example unsigned int i assume ints are 16 bits wide i 240 137 this should be okay right A quick check with your calculator reveals that 240 137 is 32880 which can easily be stored in an unsigned int but a warning is produced Why Because 240 and 137 and both signed int values Therefore the result of the multiplication must also be a signed int value but a signed int cannot hold the value 32880 Both operands are constant values so the code generator can evaluate this expression at compile time but it must do so following all the ANSI rules The following code forces the multiplication to be performed with an unsigned result i 240u 137 force at least one operand to be unsigned 373 Error and Warning Messages 752 conversion to shorter data type Code Generator Truncation may occur in this expression as the lvalue is of shorter type than the rvalue e g char a ante bp C a b t c int to char conversion may result in truncation 753 undefined shift bits Code Generator An attempt has been made to shift a value by a number of bits equal to or greater than the number of bits in the data type This will produce an undefined result on many processors This is non portable code and is flagged as having undefined results by the C Standard e g int input input lt lt 33 oops that shifts the entire value out 754 bitfield comparison out of
163. ame type The compiler will automatically convert the operands if necessary so they have the same type The conversion is to a larger type so there is no loss of information Even if the operands have the same type in some situations they are converted to a different type before the operation This conversion is called integral promotion HI TECH C PRO for the PIC32 MCU Family performs these integral promotions where required If you are not aware that these changes of type have taken place the results of some expressions are not what would normally be expected Integral promotion is the implicit conversion of enumerated types signed or unsigned varieties of char short int or bitfield types to either signed int or unsigned int If the result of the conversion can be represented by an signed int then that is the destination type otherwise the conversion is to unsigned int Consider the following example unsigned char count a 0 b 50 if a b lt 10 count The unsigned char result of a b is 206 which is not less than 10 but both a and b are con verted to signed int via integral promotion before the subtraction takes place The result of the subtraction with these data types is 50 which is less than 10 and hence the body of the if state ment is executed If the result of the subtraction is to be an unsigned quantity then apply a cast For example if unsigned int a b lt 10 count The comparison is then
164. an internal compiler error Contact HI TECH Software technical support with details 233 bad Q option Parser This is an internal compiler error Contact HI TECH Software technical support with details 234 close error Parser This is an internal compiler error Contact HI TECH Software technical support with details 236 simple integer expression required Parser A simple integral expression is required after the operator used to associate an absolute address with a variable e g int address char LOCK address 237 function redefined Parser More than one definition for a function has been encountered in this module Function overloading is illegal e g int twice int a return a 2 only one prototype amp definition of rv can exist long twice long a return a 2 310 Error and Warning Messages 238 illegal initialisation Parser You can t initialise a typedef declaration because it does not reserve any storage that can be ini tialised e g oops uint is a type not a variable typedef unsigned int uint 99 239 identifier redefined from line Parser This identifier has already been defined in the same scope It cannot be defined again e g int a a filescope variable called a int a attempting to define another of the same name Note that variables with the same name but defined with different scopes are legal
165. an internal compiler error Contact HI TECH Software technical support with details 464 missing key in avmap file Linker This is an internal compiler error Contact HI TECH Software technical support with details 465 undefined symbol in FNBREAK record Linker The linker has found an undefined symbol in the FNBREAK record for a non reentrant function Con tact HI TECH Support if this is not handwritten assembler code 466 undefined symbol in FNINDIR record Linker The linker has found an undefined symbol in the FNINDIR record for a non reentrant function Con tact HI TECH Support if this is not handwritten assembler code 467 undefined symbol in FNADDR record Linker The linker has found an undefined symbol in the FNADDR record for a non reentrant function Contact HI TECH Support if this is not handwritten assembler code 349 Error and Warning Messages 468 undefined symbol in FNCALL record Linker The linker has found an undefined symbol in the FNCALL record for a non reentrant function Contact HI TECH Support if this is not handwritten assembler code 469 undefined symbol in FNROOT record Linker The linker has found an undefined symbol in the FNROOT record for a non reentrant function Contact HI TECH Support if this is not handwritten assembler code 470 undefined symbol in FNSIZE record Linker The linker has found an undefined symbol in the FNS1ZE record for a
166. and line and the following output is observed parser 362 12 main c redundant amp applied to array linker 492 attempt to position absolute psect text is illegal Note that now the warning and error formats have changed to that requested For the case of the linker error there is no line number information so the replacement for this placeholder is left blank 2 5 5 Changing Message Behaviour Both the attributes of individual messages and general settings for messaging system can be modified during compilation There are both driver command line options and C pragmas that can be used to achieve this 40 PICC32 Command line Driver PICC32 Driver Option Descriptions 2 5 5 1 Disabling Messages Each warning message has a default number indicating a level of importance This number is speci fied in the MDF and ranges from 9 to 9 The higher the number the more important the warning Warning messages can be disabled by adjusting the warning level threshold using the WARN driver option see Section 2 6 57 Any warnings whose level is below that of the current threshold are not displayed The default threshold is O which implies that only warnings with a warning level of 0 or higher will be displayed by default The information in this option is propagated to all compiler applications so its effect will be observed during all stages of the compilation process Warnings may also be disabled by using the MSGDISABLE option see Secti
167. ar after LOCAL Assembler The list of labels after the directive LOCAL may not include any of the formal parameters to the macro e g mmm macro al move r0 Hal LOCAL al oops the macro parameter cannot be used with local ENDM 799 REPT argument must be gt 0 Assembler The argument to a REPT directive must be greater than zero e g rept 2 2 copies of this code move r0 r1 endm 800 undefined symbol Assembler The named symbol is not defined in this module and has not been specified GLOBAL 801 range check too complex Assembler This is an internal compiler error Contact HI TECH Software technical support with details 802 invalid address after END directive Assembler The start address of the program which is specified after the assembler END directive must be a label in the current file 803 undefined temporary label Assembler A temporary label has been referenced that is not defined Note that a temporary label must have a number gt 0 804 write error on object file Assembler The assembler failed to write to an object file This may be an internal compiler error Contact HI TECH Software technical support with details 381 Error and Warning Messages 805 non whitespace ignored after END directive Assembler The END directive if used indicates the end of the source file If there are non whitespace characters after the END directive then the directive is d
168. arting with the character sequence xyz then the option Xxyz would be used If a digit appears in the character sequence then this will match any digit in the symbol e g XX0 would exclude any symbols starting with the letter X followed by a digit CREF will accept wildcard filenames and I O redirection Long command lines may be supplied by invoking CREF with no arguments and typing the command line in response to the cref gt prompt A backslash at the end of the line will be interpreted to mean that more command lines follow 5 13 Cromwell The CROMWELL utility converts code and symbol files into different formats The formats available are shown in Table 5 6 The general form of the CROMWELL command is CROMWELL options input_files okey output_file where options can be any of the options shown in Table 5 7 Output_file optional is the name of the output file The input_files are typically the HEX and SYM file CROMWELL automatically searches for the SDB files and reads those if they are found The options are further described in the following paragraphs 162 Linker and Utilities Cromwell Table 5 7 CROMWELL command line options Option Description Pname architecture Processor name and architecture N Identify code classes D Dump input file Identify input files only F Fake local symbols as global Okey Set the output format Ikey Set the input format L List the available f
169. ash memory _ INTERRUPTS_RAM interrupts ram To indicate that the current interrupt scheme uses ram vectors _INTERRUPTS_ROM interrupts rom or by default To indicate that the current interrupt scheme uses rom vectors _INTERRUPTS_NONE interrupts none To indicate that no interrupt vector scheme 1s to be employed _DEFAULT_ISA_MIPS32R2 isa mips32r2 or by default To indicate that the default ISA is MIPS32r2 DEFAULT_ISA_MIPS16E isa mipsl6e To indicate that the default ISA is MIPS l6e 98 C Language Features Preprocessing Table 3 6 Preprocessor directives Directive Meaning Example preprocessor null directive do nothing assert generate error if condition false assert SIZE gt 10 asm signifies the beginning of in line asm assembly mov r0 rih endasm define define preprocessor macro define SIZE 5 define FLAG define add a b a b elif short for telse if see ifdef else conditionally include source lines see if endasm terminate in line assembly see asm endif terminate conditional source see if inclusion error generate an error message error Size too big if include source lines if constant if SIZE lt 10 expression true c process 10 else skip endif ifdef include source lines if preprocessor ifdef FLAG symbol defined do_loop elif SIZE skip_loop endif ifndef include source lines
170. asses of the compiler e g if CHAR ab define MULTI endif 175 division by zero in if zero result assumed Preprocessor Inside a if expression there is a division by zero which has been treated as yielding zero e g if foo 0 divide by 0 was this what you were intending int a endif 176 missing newline Preprocessor A new line is missing at the end of the line Each line including the last line must have a new line at the end This problem is normally introduced by editors 177 symbol in U option was never defined Preprocessor A macro name specified in a U option to the preprocessor was not initially defined and thus cannot be undefined 179 nested comments Preprocessor This warning is issued when nested comments are found A nested comment may indicate that a previous closing comment marker is missing or malformed e g output 0 a comment that was left unterminated flag TRUE next comment hey where did this line go 180 unterminated comment in included file Preprocessor Comments begun inside an included file must end inside the included file 300 Error and Warning Messages 181 non scalar types can t be converted to other types Parser You can t convert a structure union or array to another type e g struct TEST test struct TEST sp sp test oops did you mean sp amp test 182 illegal conversion between types
171. at is the range for this class Maybe you meant ACODE 0h 1fffh 443 bad low address in A spec Linker The low address given in a A specification is invalid it should be a valid number in decimal octal or hexadecimal radix The radix is specified by a trailing O for octal or H for hex A leading 0x may also be used for hexadecimal Case in not important for any number or radix Decimal is default e g ACODE 1fff 3fffh Did you forget the radix ACODE 1fffh 3fffh 444 expected in A spec Linker There should be a minus sign between the high and low addresses in a A linker option e g AROM 1000h maybe you meant AROM 1000h 1fffh 445 bad high address in A spec Linker The high address given in a A specification is invalid it should be a valid number in decimal octal or hexadecimal radix The radix is specified by a trailing O for octal or H for hex A leading 0x may also be used for hexadecimal Case in not important for any number or radix Decimal is the default e g ACODE 0h ffff Did you forget the radix ACODE 0h ffffh See Section 5 7 20 for more information 346 Error and Warning Messages 446 bad overrun address in A spec Linker The overrun address given in a A specification is invalid it should be a valid number in decimal octal or hexadecimal radix The radix is specified by a trailing O for octal or H for hex A leading 0x may also be used
172. at the file or directory is valid and that has read only access 1241 bad start address in Driver The start of range address for the CHECKSUM option could not be read This value must be a hexadecimal number 1242 bad end address in Driver The end of range address for the CHECKSUM option could not be read This value must be a hexadecimal number 1243 bad destination address in Driver The destination address for the CHECKSUM option could not be read This value must be a hexadec imal number 1245 value greater than zero required for Hexmate The align operand to the HEXMATE FIND option must be positive 1246 no RAM defined for variable placement Code Generator No memory has been specified to cover the banked RAM memory 1247 no access RAM defined for variable placement Code Generator No memory has been specified to cover the access bank memory 409 Error and Warning Messages 1248 symbol encountered with undefined type size Code Generator The code generator was asked to position a variable but the size of the variable is not known This is an internal compiler error Contact HI TECH Software technical support with details 1255 conflicting paths for output directory Driver The compiler has been given contradictory paths for the output directory via any of the O or OUTDIR options e g outdir o main hex 1256 undefined symbol treated as
173. ate operations may be possible from the compiler s command line driver How ever if hexmate is to be run directly its usage is hexmate lt filel hex fileN hex gt lt options gt Where file hex through to fileN hex are a list of input Intel hex files to merge using hexmate Ad ditional options can be provided to further customize this process Table 5 9 lists the command line options that hexmate accepts The input parameters to hexmate are now discussed in greater detail Note that any integral values supplied to the hexmate options should be entered as hexadecimal values without leading 0x or trailing h characters Note also that any address fields specified in these options are to be entered as byte addresses unless specified otherwise in the ADDRESSING option 5 14 1 1 specifications filename hex Intel hex files that can be processed by hexmate should be in either INHX32 or INHX8M format Additional specifications can be applied to each hex file to put restrictions or conditions on how this file should be processed If any specifications are used they must precede the filename The list of specifications will then be separated from the filename by a comma A range restriction can be applied with the specification rStart End A range restriction will cause only the address data falling within this range to be used For example r100 1FF myfile hex 166 Linker and Utilities Hexmate Table 5 9 Hexmate command line o
174. ate to general execution of the linker path and file names for various input and output support files and the chip type etc These are followed by the memory allocation options e g A and p Last are the input object and library files that will be linked to form the output The linker command line should be used to confirm that driver options that control the link step have been specified correctly and at the correct time It is particularly useful when using the driver L option see Section 2 6 7 TUTORIAL CONFIRMING LINKER OPERATION A project requires that a number of memory lo cations be reserved For the compiler and target device used by the project the ROM driver option is suitable for this task How can the operation of this option be confirmed First the program is compiled without using this option and the following linker class definition is noted in the linker command line ACODE 0 03FFFhx2 The class name may vary between compilers and the selected target device however there is typically a class that is defined to cover the entire memory space used by the device The driver option ROM default 4000 400F is then used and the map file resulting from the subsequent build shows the following change ACODE 0 03FFFh 04010h O7FFFh which confirms that the memory option was seen by the linker and that the memory requested was reserved 150 Linker and Utilities Map Files 5 9 2 2 Psect Information listed b
175. atol function scans the character string passed to it skipping leading blanks It then converts an ASCII representation of a decimal number to a long integer Example include lt stdlib h gt include lt stdio h gt void main void char buf 80 long i gets buf i atol buf printf Read s converted to ld n buf i See Also atoi atof Return Value A long integer If no number is found in the string O will be returned 189 Library Functions BSEARCH Synopsis include lt stdlib h gt void bsearch const void key void base size_t n_memb size_t size int compar const void const void Description The bsearch function searches a sorted array for an element matching a particular key It uses a binary search algorithm calling the function pointed to by compar to compare elements in the array Example 190 include lt stdlib h gt include lt stdio h gt include lt string h gt struct value char name 40 int value values 100 int val_cmp const void pl const void p2 return strcmp const struct value p1 gt name const struct value p2 gt name void main void char inbuf 80 int i struct value vp Library Functions i 0 while gets inbuf sscanf inbuf s d values i name amp values i value itt qsort values i sizeof values 0 val_cmp vp bsearch fred values i sizeo
176. b 9 break default then what is this b 10 break 245 default case not in switch Parser A label has been encountered called default but it is not enclosed by a switch statement A default label is only legal inside the body of a switch statement If there is a switch statement before this default label there may be one too many closing braces in the switch code which would prematurely terminate the switch statement See example for Error Message case not in switch on page 246 case label not in switch Parser A case label has been encountered but there is no enclosing switch statement A case label may only appear inside the body of a switch statement If there is a switch statement before this case label there may be one too many closing braces in the switch code which would prematurely terminate the switch statement e g 312 Error and Warning Messages switch input case 0 count break case 1 if count gt MAX count 0 oops this shouldn t be here break case 2 error flagged here 247 duplicate label Parser The same name is used for a label more than once in this function Note that the scope of labels is the entire function not just the block that encloses a label e g start if a gt 256 goto end start error flagged here if a 0 goto start which start label do I jump to 248 inappropriate else Parser An
177. being interpreted by PICC32 For example if the option L FOO is specified the F00 option will be passed on to the linker The linker will then process this option when and if it is invoked and perform the appropriate function or issue an error if the option is invalid Take care with command line options The linker cannot interpret driver options sim ilarly the command line driver cannot interpret linker options In most situations it is always the command line driver PICC32 that is being executed If you need to add 45 PICC32 Driver Option Descriptions PICC32 Command line Driver alternate settings in the linker tab in an MPLAB Build options dialogue these are the driver options not linker options but which are used by the driver to generate the appropriate linker options during the linking process The L option is especially useful when linking code which contains non standard program sections or psects as may be the case if the program contains assembly code which contains user defined psects Without this L option it would be necessary to invoke the linker manually to allow the linker options to be adjusted One commonly used linker option is N which sorts the symbol table in the map file by address rather than by name This would be passed to PICC32 as the option L N This option can also be used to replace default linker options If the string starting from the first character after the L up to the firs
178. ble to all compilers 5 2 Relocation and Psects The fundamental task of the linker is to combine several relocatable object files into one The object files are said to be relocatable since the files have sufficient information in them so that any references to program or data addresses e g the address of a function within the file may be adjusted according to where the file is ultimately located in memory after the linkage process Thus the file is said to be relocatable Relocation may take two basic forms relocation by name i e 137 Program Sections Linker and Utilities relocation by the ultimate value of a global symbol or relocation by psect i e relocation by the base address of a particular section of code for example the section of code containing the actual executable instructions 5 3 Program Sections Any object file may contain bytes to be stored in memory in one or more program sections which will be referred to as psects These psects represent logical groupings of certain types of code bytes in the program In general the compiler will produce code in three basic types of psects although there will be several different types of each The three basic kinds are text psects containing executable code data psects containing initialised data and bss psects containing uninitialised but reserved data The difference between the data and bss psects may be illustrated by considering two external variables one is initi
179. bol file class names associated with each symbol and a segments section which lists each class name and the range of memory it occupies This format is recommended if the code is to be run in conjunction with a debugger The optional argument symfile specifies a file to receive the symbol file The default file name is 1 sym 5 7 12 Jerrcount The linker will stop processing object files after a certain number of errors other than warnings The default number is 10 but the J option allows this to be altered 5 7 13 K For compilers that use a compiled stack the linker will try and overlay function auto and parameter areas in an attempt to reduce the total amount of RAM required For debugging purposes this feature can be disabled with this option 143 Operation Linker and Utilities 5 7 14 I Usually failure to resolve a reference to an undefined symbol is a fatal error Use of this option will cause undefined symbols to be treated as warnings instead 5 7 15 L When the linker produces an output file it does not usually preserve any relocation information since the file is now absolute In some circumstances a further relocation of the program will be done at load time e g when running a exe file under DOS or a prg file under TOS This requires that some information about what addresses require relocation is preserved in the object and subsequently the executable file The L option will generate in the output file
180. c variables data These psects contain initialised global or static variables These psects will be wholly placed within a RAM bank and so can be accessed more efficiently nvram This psect is used to store non bit persistent variables It is not cleared or otherwise modified at startup nvbit This psect holds persistent bit objects It is not cleared or otherwise modified at startup rbit These psects are used to store all bit variables 86 C Language Features Interrupt Handling in C stack This psect contains the program stack heap This psect contains the program heap heapstack This psect contains the program heap and stack 3 9 Interrupt Handling in C The compiler incorporates features allowing interrupts to be handled from C code Interrupt func tions are often called interrupt service routines ISR Interrupts are also known as exceptions PIC32 devices have 64 separate interrupt vectors servicing 96 external interrupts and a priority scheme to determine which interrupts are serviced first See the device datasheet for more detailed information 3 9 1 Interrupt Functions Functions of void type and void parameters may be qualified interrupt Functions qualified in this manner will be generated with the necessary context handling code depending on its intended duty The duty of an interrupt function can be specified at compile time and or runtime depending on the interrupt vector table type specified To specify the dut
181. cal support with details 785 too many temporary labels Assembler There are too many temporary labels in this assembler file The assembler allows a maximum of 2000 temporary labels 787 can t handle v_rtype of in copyexpr Assembler This is an internal compiler error Contact HI TECH Software technical support with details 788 invalid character in number Assembler A number contained a character that was not part of the range 0 9 or 0 F 790 end of file inside conditional Assembler END of FILE was encountered while scanning for an endif to match a previous if 793 unterminated macro argument Assembler An argument to a macro is not terminated Note that angle brackets lt gt are used to quote macro arguments 794 invalid number syntax Assembler Optimiser The syntax of a number is invalid This can be e g use of 8 or 9 in an octal number or other malformed numbers 796 use of LOCAL outside macros is illegal Assembler The LOCAL directive is only legal inside macros It defines local labels that will be unique for each invocation of the macro 797 syntax error in LOCAL argument Assembler A symbol defined using the LOCAL assembler directive in an assembler macro is syntactically incor rect Ensure that all symbols and all other assembler identifiers conform with the assembly language of the target device 380 Error and Warning Messages 798 macro argument may not appe
182. cally the command line driver PICC32 is used to envoke the assembler as it can be passed assembler source files as input however the options for the assembler are supplied here for instances 109 Assembler Options Macro Assembler where the assembler is being called directly or when they are specified using the command line driver option SETOPTION see Section 2 6 51 The usage of the assembler is similar under all of available operating systems All command line options are recognised in either upper or lower case The basic command format is shown ASPIC32 options files files is a space separated list of one or more assembler source files Where more than one source file is specified the assembler treats them as a single module i e a single assembly will be performed on the concatenation of all the source files specified The files must be specified in full no default extensions or suffixes are assumed options is an optional space separated list of assembler options each with a minus sign as the first character A full list of possible options is given in Table 4 1 and a full description of each option follows Table 4 1 ASPIC32 command line options Option Meaning Default A Produce assembler output Produce object code C Produce cross reference file No cross reference Cchipinfo Define the chipinfo file dat picc 32 ini E file digit Set error destination forma
183. ccessed in the commented instruction is associated with a variable that was declared as volatile in the C source code Accesses to this location which appear to be redundant will not be removed by the assembler optimizer if this string is present This comment string may also be used in assembler source to achive the same effect for locations defined and accessed in assembly code 4 3 6 Constants 4 3 6 1 Numeric Constants The assembler performs all arithmetic with signed 32 bit precision The default radix for all numbers is 10 Other radices may be specified by a trailing base specifier as given in Table 4 5 Hexadecimal numbers must have a leading digit e g Offffh to differentiate them from identi fiers Hexadecimal digits are accepted in either upper or lower case 116 Macro Assembler HI TECH C Assembly Language Table 4 5 ASPIC32 numbers and bases Radix Format Binary digits O and 1 followed by B Octal digits 0 to 7 followed by O Q o or q Decimal digits O to 9 followed by D d or nothing Hexadecimal digits 0 to 9 A to F preceded by Ox or followed by H or h Note that a binary constant must have an upper case B following it as a lower case b is used for temporary numeric label backward references In expressions real numbers are accepted in the usual format and are interpreted as IEEE 32 bit format 4 3 6 2 Character Constants and Strings A character constant is a single character e
184. char ltoa char buf long val int base Description The function itoa converts the contents of val into a string which is stored into buf The conversion is performed according to the radix specified in base buf is assumed to reference a buffer which has sufficent space allocated to it Example include lt stdlib h gt include lt stdio h gt void main void char buf 10 utoi buf 12345678L 16 printf The buffer holds s n buf See Also strtol itoa utoa ultoa Return Value This routine returns a copy of the buffer into which the result is written 224 Library Functions MEMCMP Synopsis include lt string h gt int memcmp const void sl const void s2 size_t n Description The memcmp function compares two blocks of memory of length n and returns a signed value similar to strncmp Unlike strncmp the comparison does not stop on a null character Example tinclude lt stdio h gt tinclude lt string h gt void main void int buf 10 cow 10 i buf 0 1 buf 2 4 cow 0 1 cow 2 5 buf 1 3 cow 1 3 i memcmp buf cow 3 sizeof int if i lt 0 printf less than n else if i gt 0 printf Greater than n else printf Equal n 225 Library Functions See Also strncpy stracmp strchr memset memchr Return Value Returns negative one zero or one depending on whe
185. cii macro returns a result that is guaranteed in the range 0 0177 The functions toupper and tolower return their arguments if it is not an alphabetic character Example include lt stdio h gt include lt ctype h gt include lt string h gt void main See Also void char arrayl aBcDE int i for i 0 i lt strlen arrayl i printf Sc tolower arrayl i printf n islower isupper isascii et al 277 Library Functions TRUNC Synopsis include lt math h gt double trunc double x Description The trunc function rounds the argument to the nearest integer value in floating point format that is not larger in magniture than the argument Example include lt math h gt void main void double input rounded input 1234 5678 rounded trunc input See Also round 278 Library Functions UDIV Synopsis include lt stdlib h gt int udiv unsigned num unsigned demon Description The udiv function calculate the quotient and remainder of the division of number and denon storing the results into a udiv_t structure which is returned Example include lt stdlib h gt void main void udiv_t result unsigned num 1234 den 7 result udiv num den See Also uldiv divO IdivO Return Value Returns the the quotient and remainder as a udiv_t structure 279 Library Functions ULDIV Synopsis
186. cimal digit a non zero value otherwise 214 Library Functions ITOA Synopsis include lt stdlib h gt char itoa char buf int val int base Description The function itoa converts the contents of val into a string which is stored into buf The conversion is performed according to the radix specified in base buf is assumed to reference a buffer which has sufficent space allocated to it Example include lt stdlib h gt include lt stdio h gt void main void char buf 10 itoa buf 1234 16 printf The buffer holds s n buf See Also strtol utoa ltoa ultoa Return Value This routine returns a copy of the buffer into which the result is written 215 Library Functions LABS Synopsis include lt stdlib h gt int labs long int j Description The labs function returns the absolute value of long value j Example include lt stdio h gt include lt stdlib h gt void main void long int a 5 printf The absolute value of bld is ld n a labs a See Also abs Return Value The absolute value of j 216 Library Functions LDEXP Synopsis include lt math h gt double ldexp double f int i Description The Idexp function performs the inverse of frexp operation the integer i is added to the exponent of the floating point f and the resultant returned Example include lt math h gt include lt stdio h
187. clude lt stdio h gt void main void int i if i strcmp ABC ABc lt 0 printf ABC is less than ABc n else if i gt 0 printf ABC is greater than ABc n else printf ABC is equal to ABc n See Also strlen strncmp strepy streat 253 Library Functions Return Value A signed integer less than equal to or greater than zero Note Other C implementations may use a different collating sequence the return value is negative zero or positive i e do not test explicitly for negative one 1 or one 1 254 Library Functions STRCPY Synopsis include lt string h gt char strcpy char sl const char s2 Description This function copies a null terminated string s2 to a character array pointed to by s1 The destination array must be large enough to hold the entire string including the null terminator Example include lt string h gt include lt stdio h gt void main void char buffer 256 char sl s2 strcpy buffer Start of line sl buffer s2 end of line strcat sl s2 printf Length d n strlen buffer printf string s n buffer See Also stmepy strlenQ streat strlen Return Value The destination buffer pointer s1 is returned 255 Library Functions STRCSPN Synopsis include lt string h gt size_t strcspn const char sl const char s2 Description
188. code see Section 3 3 9 Variables qualified as volatile will never be removed by the code generator even if they appear to be unused throughout the program TUTORIAL PROCESSING OF UNDEFINED SYMBOLS A C source module defines a global variable as follows 95 Preprocessing C Language Features int input but this variable is only ever used in assembly code The assembly module s can simply declare and link in to this symbol using the GLOBAL assembler directive and them make use of the symbol GLOBAL _input PSECT text class CODE reloc 2 li a2 _PORTA lw a3 0 a2 sw s3 _input gptr gp TUTORIAL In this instance the C variable input will not be removed and be treated as if it was qualified volatile 3 11 Preprocessing All C source files are preprocessed before compilation Assembler files can also be preprocessed if the P command line option is issued see Section 2 6 11 3 11 1 C Language Comments HI TECH C PRO for the PIC32 MCU Family accepts both block and in line C99 standard C source comments as shown in the following examples In line comments are normally termined by the newline character however they can span multiple lines when the line is terminated with a backslash character 96 I am a block comment that can run over more than one line of source I am an in line comment I am an in line comment that spans two lines C Language Features Preprocessing Both these
189. comment styles can be used in addition to the standard assembly comment see Section 4 3 5 in assembly source code if the P command line option is issued see Section 2 6 11 All comments are removed by the C preprocessor before being passed to the parser application 3 11 2 Preprocessor Directives HI TECH C PRO for the PIC32 MCU Family accepts several specialised preprocessor directives in addition to the standard directives All of these are listed in Table 3 6 Macro expansion using arguments can use the character to convert an argument to a string and the sequence to concatenate tokens 3 11 3 Predefined Macros The compiler drivers define certain symbols to the preprocessor CPP allowing conditional com pilation based on chip type etc The symbols listed in Table 3 7 show the more common symbols defined by the drivers Each symbol if defined is equated to 1 unless otherwise stated Symbol When set Usage HI_TECH_C Always To indicate that the compiler in use is TECH C HTC_VER_MAJOR Always To indicate the integer component of compiler s version number HTC_VER_MINOR Always To indicate the decimal component of compiler s version number HTC_VER_PATCH Always To indicate the patch level of the cc piler s version number _ PICC32__ Always To indicate the use of the HI TECH PIC 32 compiler _PIC32 Always To indicate that this is a PIC32 device _chipname When chip sele
190. compilation includ ing C code generation assembly and link steps It is the recommended way to use the compiler as it hides the complexity of all the internal applications used in the compilation process and provides a consistent interface for all compilation steps This chapter describes the steps the driver takes during compilation files that the driver can accept and produce as well as the command line options that control the compiler s operation WHAT IS THE COMPILER Throughout this manual the term the compiler is used to refer to either all or some subset of the collection of applications that form the HI TECH C PRO for the PIC32 MCU Family package Often it is not important to know for example whether an action is performed by the parser or code generator application and it is sufficient to say it was performed by the compiler It is also reasonable for the compiler to refer to the command line driver or just driver PICC32 as this is the application executed to invoke the compilation process Following this view compiler options should be considered command line driver op tions unless otherwise specified in this manual Similarly compilation refers to all or some part of the steps involved in generating source code into an executable binary image Invoking the Compiler PICC32 Command line Driver Table 2 1 PICC32 input file types File Type
191. compiler only supports devices from these architecture families 683 bank 1 variables are not supported by the PICC Lite compiler Code Generator A variable with an absolute address located in bank 1 was detected This compiler does not support code generation of variables in this bank 684 bank 2 and 3 variables are not supported by the PICC Lite compiler Code Generator A variable with an absolute address located in bank 2 or 3 was detected This compiler does not support code generation of variables in these banks 689 unknown predicate Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 695 duplicate case label Code Generator There are two case labels with the same value in this switch statement e g switch in case 0 if this is case 0 D break case 0 then what is this case b break 696 out of range case label Code Generator This case label is not a value that the controlling expression can yield and thus this label will never be selected 697 non constant case label Code Generator A case label in this switch statement has a value which is not a constant 366 Error and Warning Messages 699 no case labels in switch Code Generator There are no case labels in this switch statement e g switch input there is nothing to match the value of input 700 truncation of e
192. cted To indicate the specific chip type select __chipname__ Always To indicate the target device FILE Always To indicate this source file being prep cessed LINE __ Always To indicate this source line number __ DATE _ Always To indicate the current date e g May 2004 continued 97 Preprocessing C Language Features __ TIME Always To indicate the current time e g 08 06 31 __LANGUAGE_C__ Always To indicate the target language _PLIB runtime plib To indicate that the peripheral libraries have been linked in _ OPTIMIZE_SPEED__ opt speed To indicate that compiler optimisations have focused on speed _ OPTIMIZE_SIZE__ opt size To indicate that compiler optimisations have focused on size _INTERRUPTS_SINGLE interrupts single To indicate that the current interrupt scheme uses a single interrupt vector _ INTERRUPTS _MULTI interrupts multi or by default To indicate that the current interrupt scheme uses a multiple interrupt vectors _INTERRUPTS_GENEX interrupts genex To indicate that the current interrupt scheme uses only the general exception vector _INTERRUPTS_PFM interrupts pfm To indicate that the current interrupt scheme locates the vector table in program flash memory _INTERRUPTS_BOOT interrupts boot or by default To indicate that the current interrupt scheme locates the vector table in boot fl
193. ction prototypes 106 132 function return values 81 function signatures 131 function stack frame 82 functions argument passing 81 getch 107 interrupt 87 interrupt qualifier 87 kbhit 107 putch 107 recursion 65 return values 81 signatures 105 written in assembler 88 getch function 107 207 getchar function 208 getche function 207 gets function 209 GLOBAL directive 91 118 121 global optimization 56 global PSECT flag 123 global symbols 138 gmtime function 210 hardware initialization 33 header files htc h 71 problems in 62 HEX file format 172 HEX file map 173 hex files address alignment 170 address map 165 calculating check sums 165 converting to other Intel formats 165 data record 169 detecting instruction sequences 165 embedding serial numbers 166 extended address record 172 filling unused memory 52 165 find and replacing instructions 165 merging multiple 165 multiple 142 record length 165 170 172 hexadecimal constants assembly 116 hexmate application 23 165 hexmate option 427 INDEX INDEX prefix 168 CK 169 FILL 170 173 FIND 171 FIND DELETE 172 FIND REPLACE 172 FORMAT 172 HELP 173 LOGFILE 173 MASK 174 O 174 SERIAL 62 174 SIZE 175 STRING 175 STRPACK 176 addressing 168 break 169 file specifications 166 hexmate options 166 HI TIDE 52 HI_TECH_C 97 htc h 71 94 HTC_ERR_FORMAT 38 HTC_MSG_FORMA
194. ctions must be written Other routines which may be required include getche and kbhit You will find samples of serial code which implements the putch and getch functions in the file serial c in the SAMPLES directory 107 Standard I O Functions and Serial I O C Language Features 108 Chapter 4 Macro Assembler The Macro Assembler included with HI TECH C PRO for the PIC32 MCU Family assembles source files for PIC32 MCUs This chapter describes the usage of the assembler and the directives assem bler pseudo ops and controls accepted by the assembler in the source files The HI TECH C Macro Assembler package includes a linker librarian cross reference generator and an object code converter Athough the term assembler is almost universally used to decribe the tool which con verts human readable mnemonics into machine code both assembler and assembly are used to describe the source code which such a tool reads The latter is more com mon and is used in this manual to describe the language Thus you will see the terms assembly language or just assembly assembly listing and etc but assembler options assembler directive and assembler optimizer 4 1 Assembler Usage The assembler is called ASPIC32 and is available to run on Windows Linux and Mac OS systems Note that the assembler will not produce any messages unless there are errors or warnings there are no assembly completed messages Typi
195. d The ordering of the modules in a library is significant to the linker If a library contains a module which references a symbol defined in another module in the same library the module defining the symbol should come after the module referencing the symbol 5 10 7 Error Messages LIBR issues various error messages most of which represent a fatal error while some represent a harmless occurrence which will nonetheless be reported unless the W option was used In this case all warning messages will be suppressed 5 11 Objtohex The HI TECH linker is capable of producing simple binary files or object files as output Any other format required must be produced by running the utility program OBJTOHEX This allows conversion of object files as produced by the linker into a variety of different formats including various hex formats The program is invoked thus OBJTOHEX options inputfile outputfile All of the arguments are optional If output file is omitted it defaults to 1 hex or 1 bin depend ing on whether the b option is used The input file defaults to 1 obj The options for OBJTOHEX are listed in Table 5 4 Where an address is required the format is the same as for HLINK 5 11 1 Checksum Specifications If you are generating a HEX file output please refer to the hexmate section 5 14 for calculating checksums For OBJTOHEX the checksum specification allows automated checksum calculation and takes the form of several lines each
196. d The contin ued usage of this term is still appropriate HI TECH C PRO for the PIC32 MCU Family uses the traditional psect bss which is used for unitialized static variables However unitialized variables that are written to only once may be placed into non volatile memory nvram psect Assembly code that defines variables which should be cleared at startup should be placed in the bss psect Appropriate default linker options will be issued for bss thus it s use does not require modification of the linker options and the command line driver will automatically check the size of this psect to determine if block clear code is required Variables placed into psects other than the comipler defined bss psect will not be cleared at startup by default The block clear of the bss psect can be omitted by disabling the clear suboption of RUNTIME For example RUNTIME default clear 30 PICC32 Command line Driver Runtime Files With this part of the runtime startup code absent the contents of uninitialized variables will be unpredictable when the program begins execution Variables whose contents should be preserved over a reset or even power off should be qualified with persistent See Section 3 3 10 1 for more information Such variables are linked at a different area of memory and are not altered by the runtime startup code in anyway 2 3 2 3 System Coprocessor Initialization RUNTIME cp0 Initialise the system coprocessor
197. d and passed to the code generator and linker respectively The case of the string following the option is important for enviroments where filenames are case sensative Thus the option Lt when compiling for a 32MX360F512L will for example specify the li brary filenames pic32 t lpp and pic32 t lib The option Lxx will specify libraries called pic32 xx lpp and pic32 xx lib All libraries must be located in the LIB subdirectory of the compiler installation directory If you wish the linker to scan libraries whose names do not follow the above naming conven tion or whose locations are not in the LIB subdirectory simply include the libraries names on the command line along with your source files The commonly used HI TECH C PRO for the PIC32 MCU Family Standard compiler options L1 Lf and Lw should not be used for altering the behaviour of the printf function The library files corresponding to these opptions are not provided with the PRO version of this compiler and an error will result if these options are used with creating these library sets A custom printf function is automatically generated by the compiler when required as descibed in section 2 3 4 2 6 7 L option Adjust Linker Options Directly The L driver option can also be used to specify an option which will be passed directly to the linker If L is followed immediately by text starting with a dash character the text will be passed directly to the linker without
198. d a value has been dereferenced This can result in erroneous behaviour at runtime 1235 unknown keyword Driver The token contained in the USB descriptor file was not recognised 1236 invalid argument to Driver An option that can take additional parameters was given an invalid parameter value Check the usage of the option or the syntax or range of the expected parameter 1237 endpoint 0 is pre defined Driver An attempt has been made to define endpoint 0 in a USB file This channel c 1238 FNALIGN failure on Linker Two functions have their auto parameter blocks aligned using the FNALIGN directive but one func tion calls the other which implies that must not be aligned This will occur if a function pointer is assigned the address of each function but one function calls the other For example int one int a return a int two int a return two a 2 int ip int ip one ip 23 ip two ip references one and two two calls one ip 67 408 Error and Warning Messages 1239 pointer has no valid targets Code Generator A function call involving a function pointer was made but the pointer was never assigned a target address e g void fp int fp 23 oops what function does fp point to 1240 unknown checksum algorithm type i Driver The error file specified after the Efile or E file options could not be opened Check to ensure th
199. d by default and this option is not required for normal compilation The usable suboptions include those shown in Table 2 13 Suboption Controls On implies init The code present in the startup module that The idata ibigdata and copies the idata ibigdata and ifardata ifardata psects ROM image is psects ROM image to RAM copied into RAM clib The inclusion of library files into the output Library files are linked into the code by the linker output clear The code present in the startup module that The bss bigbss and farbss clears the bss bigbss and farbss psects psects are cleared config The driver will check that the config words Any unprogrammed config words at the top of boot flash have been pro will be set to configure the device grammed using the _ CONFIG macro defined to operate at maximum speed and in lt pic32 h gt See Section 2 3 2 6 for debugging keep Whether the start up module source file is The start up module is not deleted after compilation deleted no_startup Whether the startup module is linked in with user defined code The start up module is generated and linked into the program stackwarn Checking the depth of the stack used The stack depth is monitored at compile time 60 PICC32 Command line Driver PICC32 Driver Option Descriptions Suboption Controls On implies nmi Test fo
200. d have permanent duration 3 4 1 1 Auto Variables auto short for automatic variables are the default type of local variable Unless explicitly declared to be static a local variable will be made auto however the auto keyword may be used if desired Note that most type qualifiers cannot be used with auto variables since there is no control over the storage location The exceptions are const and volatile All auto variables exist for their duration in the stack As such they will not appear as symbols in the map file 3 4 1 2 Static Variables Uninitialized static variables are allocated in the bss psect They will occupy fixed memory locations which will not be overlapped by storage for other functions Static variables are local in scope to the function in which they are declared but may be accessed by other functions via pointers since they have permanent duration Static variables are guaranteed to retain their value between 79 Storage Class and Object Placement C Language Features calls to a function unless explicitly modified via a pointer Static variables are not subject to any architectural limitations on the PIC32 Static variables which are initialised are allocated in the data psect are only initialised once during the program s execution Thus they may be preferable over initialised auto objects which are assigned a value every time the block in which the definition is placed is executed 3 4 2 Absolute Variables
201. d line Driver PICC32 Driver Option Descriptions 2 6 15 v Verbose Compile The V is the verbose option The compiler will display the command lines used to invoke each of the compiler applications or compiler passes Displayed will be the name of the compiler application being executed plus all the command line arguments to this application This option may be useful for determining the exact linker options if you need to directly invoke the HLINK command If this option is used twice it will display the full path to each compiler application as well as the full command line arguments This would be useful to ensure that the correct compiler installation is being executed if there is more than one installed 2 6 16 X Strip Local Symbols The option X strips local symbols from any files compiled assembled or linked Only global sym bols will remain in any object files or symbol files produced 2 6 17 ASMLIST Generate Assembler LST Files The ASMLIST option tells PICC32 to generate one or more assembler listing file for each C and assembly source module being compiled In the case of code being assembled that was originally C source the list file shows both the original C code and the corresponding assembly code generated by the code generator For both C and assembly source code a line number the binary op codes and addresses are shown If the assembler optimizer is enabled default operation the list file may differ from th
202. d type 0x Cromwell The type indicator of this record did not match any valid types for this file format 1043 unknown optional header Cromwell When reading this Microchip COFF file the optional header within the file header was of an incor rect length 1044 end of file encountered Cromwell Linker The end of the file was found while more data was expected Has this input file been truncated 1045 short read on block of bytes Cromwell A while reading a block of byte data from a UBROF record the block ended before the expected length 1046 short string read Cromwell A while reading a string from a UBROF record the string ended before the specified length 1047 bad type byte for UBROF file Cromwell This UBROF file did not begin with the correct record 1048 bad time date stamp Cromwell This UBROF file has a bad time date stamp 1049 wrong CRC on 0x bytes should be Cromwell An end record has a mismatching CRC value in this UBROF file 1050 bad date in 0x52 record Cromwell A debug record has a bad date component in this UBROF file 401 Error and Warning Messages 1051 bad date in 0x01 record Cromwell A start of program record or segment record has a bad date component in this UBROF file 1052 unknown record type Cromwell A record type could not be determined when reading this UBROF file 1058 assertion Code Generator This is an internal compiler error Contac
203. default ISA specified by the ISA option see 2 6 32 for the qualified function Note that interrupt functions can not be generated in mips16e If the default ISA is mips16e ensure all interrupt functions are qualified as mips32r2 3 3 11 Pointer Types There are two basic pointer types supported by HI TECH C PRO for the PIC32 MCU Family data pointers and function pointers Data pointers hold the address of variables which can be read and possibly written indirectly by the program Function pointers hold the address of an executable routine which can be called indirectly via the pointer As the PIC32 has a flat memory space both of these pointer types are 32 bit and are addressed in the same manner It is helpful to first review the ANSI standard conventions for definitions of pointer types 3 3 11 1 Pointers to Const The const qualifier plays no direct part in specifying the pointer classification that the compiler will allocate to a pointer This qualifier should be used when the target or targets referenced by the pointer should be read only The addresses of const objects assigned to a pointer will result in that pointer having a classification capable of accessing the program space The exact classification will also depend on other factors The code generator tracks the total size of const qualified variables that are defined It uses this information to determine how large any pointers that can access const objects must be Such point
204. dy 1d Tt ORI rt immediate ORI rt rt immediate ROTR rd sa ROTR rd rd sa ROTRV rd rs ROTRV rd rd rs SLL rd sa SLL rd rd sa SLLV rd rs SLLV rd rd rs SLT rd rt SLT rd rd rt SLTU rd rt SLTU rd rd rt SRA rd sa SRA rd rd sa SRAV rd rs SRAV rd rd rs SRL rd sa SRL rd rd sa SRLV rd rs SRLV rd rd rs SUB rd sa SUB rd rd sa SUBU rd sa SUBU rd rd sa SLTI rt immediate SLTI rt rt immediate SLTIU rt immediate SLTIU rt rt immediate XOR rd sa XOR rd rd sa XORI rt immediate XORI rt rt immediate Table 4 2 MIPS32r2 Assembly Instruction Operand Variants 115 HI TECH C Assembly Language Macro Assembler VARIANT INTERPRETATION ADDU rx ry ADDU rx rx ry NEG rx NEG YX YX SLL rx sa SLL rx YX Sa SRA rx sa SRA YX YX Sa SRL rx sa SRL YX YX Sa SUBU rx ry SUBU rx rx ry Table 4 3 MIPS16e Assembly Instruction Operand Variants Table 4 4 ASPIC32 statement formats Format 1 label Format2 label mnemonic operands comment Format 3 name pseudo op operands comment Format 4 comment only Format 5 lt empty line gt 4 3 5 1 Special Comment Strings Several comment strings are appended to assembler instructions by the code generator These are typically used by the assembler optimizer The comment string volatile is used to indicate that the memory location being a
205. e Rather than the traditional method of linking in a generic precompiled routine HI TECH C PRO for the PIC32 MCU Family uses a more efficient method which actually determines what runtime startup code is required from the user s program It does this by performing an additional link step the output of which is used to determine the requirements of the program From this information 28 PICC32 Command line Driver Runtime Files PICC32 then writes the assembler code which will perform the startup sequence This code is stored into a file which is then assembled and linked into the remainder of the program automatically The runtime startup code is generated automatically on every compilation If required the as sembler file which contains the runtime startup code can be deleted after compilation by using the driver option RUNTIME default keep If the startup module is kept it will be called startup as and will be located in the current working directory If you are using an IDE to perform the compilation the destination directory is dictated by the IDE itself however you may use the OUTDIR option to specify an explicit output directory to the compiler This is an automatic process which does not require any user interaction however some aspects of the runtime code can be controlled if required using the RUNTIME option Section 2 6 48 describes the use of this option and the following sections describes the functional a
206. e and thus should only follow the keyword enun e g enum IN ONE 1 TWO struct IN oops IN is already defined int a b hi 979 this identifier is already a struct tag Parser This identifier following a union or enum keyword is already the tag for a structure and thus should only follow the keyword struct e g struct IN int a D hi enum IN ONE 1 TWO oops IN is already defined 980 this identifier is already a union tag Parser This identifier following a struct or enum keyword is already the tag for a union and thus should only follow the keyword union e g union IN int a b hi enum IN ONE 1 TWO oops IN is already defined 395 Error and Warning Messages 981 pointer required Parser A pointer is required here e g struct DATA data data gt a 9 data is a structure not a pointer to a structure 982 unknown op in nxtuse Optimiser Assembler This is an internal compiler error Contact HI TECH Software technical support with details 983 storage class redeclared Parser A variable previously declared as being static has now be redeclared as extern 984 type redeclared Parser The type of this function or object has been redeclared This can occur because of two incompatible declarations or because an implicit declaration is followed by an incompatible declaration e g int a char a oops what is the correct type
207. e done because it needs to simultaneously read and write input and output files 400 bad object code format Linker This is an internal compiler error The object code format of an object file is invalid Ensure it is a valid HI TECH object file Contact HI TECH Software technical support with details 402 bad argument to F Objtohex The F option for objtohex has been supplied an invalid argument If you are invoking this command line tool directly then please refer to Section 5 11 for more details Otherwise this may be an internal compiler error and you should contact HI TECH Software technical support with details 403 bad E option Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 404 bad maximum length value to lt digits gt Objtohex The first value to the OBJTOHEX n m hex length rounding option is invalid 405 bad record size rounding value to lt digits gt Objtohex The second value to the OBJTOHEX n m hex length rounding option is invalid 406 bad argument to A Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 407 bad argument to U Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 341 Error and Warning Messages 408 bad argument to B Objtohex This option requires an integer argument in either base 8 10 or 16 I
208. e lt stdio h gt void main void double i_val f_val f val modf 3 17 amp i_val Return Value The signed fractional part of value 229 Library Functions PERSIST_CHECK PERSIST_VALIDATE Synopsis include lt sys h gt int persist_check int flag void persist_validate void Description The persist_check function is used with non volatile RAM variables declared with the persistent qualifier It tests the nvram area using a magic number stored in a hidden variable by a previous call to persist_validate and a checksum also calculated by persist_validate If the magic number and checksum are correct it returns true non zero If either are incorrect it returns zero In this case it will optionally zero out and re validate the non volatile RAM area by calling persist_validate This is done if the flag argument is true The persist_validate routine should be called after each change to a persistent variable It will set up the magic number and recalculate the checksum Example include lt sys h gt include lt stdio h gt persistent long reset_count void main void if persist_check 1 printf Reset count invalid zeroed n else printf Reset number ld n reset_count reset_count update count persist_validate and checksum for continue sleep until next reset 230 Library Functions Return Value FALSE zero if the NV
209. e user considers significant will be displayed In addition messages with a particular number can be disabled Both of these methods are explained in Section 2 5 5 1 Provided the message is enabled and it is not a warning messages that is below the warning threshold the message string will be displayed In addition to the actual message string there are several other pieces of information that may be displayed such as the message number the name of the file for which the message is applicable the file s line number and the application that requested the message etc If a message is being displayed as an error a counter is incremented After a certain number of errors has been reached compilation of the current module will cease The default number of errors that will cause this termination can be adjusted by using the ERRORS option see Section 2 6 26 This counter is reset after each compilation step of each module thus specifying a maximum of five errors will allow up to five errors from the parser five from the code generator five from the linker five from the driver etc 36 PICC32 Command line Driver Compiler Messages Table 2 3 Support languages Language MDF name English en_msgs txt German de_msgs txt French fr_msgs txt If a language other than English is selected and the message cannot be found in the appropriate non English MDF the alert system tries to find the message in the English MD
210. e C identifier i relate to different objects at different memory locations 93 Mixing C and Assembly Code C Language Features 3 10 3 1 Accessing special function register names from assembler If writing separate assembly modules SFR definitions will not automatically be present If writing assembly code from within a C module SFRs may be accessed by referring to the symbols defined by the chip specific C header files Whenever you include lt htc h gt into a C module all the available SFRs are defined as absolute C variables As the contents of this file is C code it cannot be included into an assembler module but assembly code can uses these definitions To use a SFR in in line assembly code from within the same C module that includes lt htc h gt simply use the symbol with an underscore character prepended to the name For example include lt htc h gt void main void PORTA 0x55FFFFFF asm li a3 O55FFFFFFh asm li a2 _PORTA asm Sw a3 0 a2 3 10 4 Interaction between Assembly and C Code HI TECH C PRO for the PIC32 MCU Family incorporates several features designed to allow C code to obey requirements of user defined assembly code The command line driver ensures that all user defined assembly files have been processed first before compilation of C source files begin The driver is able to read and analyse certain information in the relocatable object files and pass this information to the code generator
211. e Register Intialization RUNTIME gpr 2 3 2 5 The Stack and Heap RUNTIME stack RUNTIME heap 2 3 2 6 Default Configuration Words RUNTIME config 2 3 2 7 Memory Performance RUNTIME perform CONTENTS CONTENTS 2 4 23 2 6 2 33 The Powerup Routine occ Sea eee Reh a Dee Saw oO 33 25 The PEEL ROUDE o foes Gea algo ee A a A BP a 33 Debugging Internation 4i4 20b4 5455 44 bee SE Ea Se eS 35 ZAI Output File Formats ess 44 eaaa e YR RR AP Oe eS 35 DA Symbol 4 ct ee ea ee yee Ge Sees ae amp HA DEBS RS 35 Compiler Messages ss csocsi cotate DEA bE eR ee ee eS 36 2 5 1 Messaging Overview 05 6S eS ee 36 2 32 Message Language 2 cest eu Ga ae a a E 37 20 INESSISO Types s acdc do kc G e alg Boke ROR a a ph 37 aoe Message Format 2 25 425 444 545 60 be oe o i eee 38 2 5 5 Changing Message Behaviour o o tates ss 40 2331 Disabling Messages os a alee ea oh Be dS 41 25 5 2 Changing Message Types 2 see eee cares 41 PICC32 Driver Option Descriptions o o e e 41 2 6 1 C Compileto Object File sc cu cra trata eaa Pa e 42 26 2 Dinacre Define Macro sy pose e a Pe eS 42 2 6 3 Efile Redirect Compiler Errors toa File o s s s e coi o ooe ea 43 2 6 4 Gfile Generate Source level Symbol File 44 2 65 Ipath Include Search Path cc 4 6 66 224454864 6040 44 2 66 Lidbrary Scan Library gt e esere nee ee baw
212. e a different name The linker will issue this warning if the symbol C or assembler was defined multiple times in different modules The names of the modules are given in the error message Note that C identifiers often have an underscore prepended to their name after compilation 384 Error and Warning Messages 846 relocation error Assembler Optimiser It is not possible to add together two relocatable quantities A constant may be added to a relocatable value and two relocatable addresses in the same psect may be subtracted An absolute value must be used in various places where the assembler must know a value at assembly time 847 operand error Assembler Optimiser The operand to this opcode is invalid Check your assembler reference manual for the proper form of operands for this instruction 850 PAGESEL not usable with this processor Assembler The PAGESEL pseudo instruction is not usable with the device selected 856 ALIGN argument must be a positive constant Assembler The align assembler directive requires a non zero positive integer argument 857 psect may not be local and global Linker A local psect may not have the same name as a global psect e g psect text class CODE text is implicitly global move r0 rl elsewhere psect text local class CODE move r2 r4 The global flag is the default for a psect if its scope is not explicitly stated 860 page width must be gt 49 Assembler
213. e configuration macro will program the config words in the boot segment with each call Special named quantities are defined in the header file appropriate for the processor you are using to help you enable the required features 66 C Language Features Supported Data Types and Variables For example to set a PIC32Cxx1 chip to have Code Protect and Boot Flash write protect dis abled ICE Communication Channnel enabled and the watchdog timer enabled with a post scale factor of 1 1 the following could be used include lt htc h gt _ CONFIG DEVCFGO GCP_OFF amp BWP_OFF amp ICS _PGx1 _ CONFIG DEVCFG1 FWDTEN_ON amp WDTPS 0 Note that the individual selections are ANDed together Any bits which are not selected in these macros will remain unprogrammed You should ensure that you have specified all bits correctly to ensure proper operation of the part when programmed Consult your PIC32 datasheet for more details The __ CONFIG macro does not produce executable code 3 2 3 Multi byte SFRs The SFRs associated with the PIC32 are 32 bits wide Although it is possible to define an absolute C variable to map over such registers it is highly recommended that the existing SFR definitions included via lt htc h gt are used Each SFR should be accessed directly and in the required order by the programmer s code This will ensure a much higher degree of portability 3 3 Supported Data Types and Variables The HI TECH C PRO for t
214. e declaration indicates that the member is a bitfield An integral constant must appear after the colon to define the number of bits in the bitfield e g struct unsigned first oops should be unsigned first unsigned second my_struct If this was meant to be a structure with bitfields then the following illustrates an example struct unsigned first 4 4 bits wide unsigned second 4 another 4 bits my_struct 266 storage class illegal Parser A structure or union member may not be given a storage class Its storage class is determined by the storage class of the structure e g struct no additional qualifiers may be present with members static int first LG 267 bad storage class Code Generator The code generator has encountered a variable definition whose storage class is invalid e g auto int foo auto not permitted with global variables int power static int a parameters may not be static return foo a 317 Error and Warning Messages 268 inconsistent storage class Parser A declaration has conflicting storage classes Only one storage class should appear in a declaration e g extern static int where so is it static or extern 269 inconsistent type Parser Only one basic type may appear in a declaration e g int float if is it int or float 270 variable can t have storage class register Parser Only functio
215. e e epen a A eR AS Bas 80 So PUNCUONS oops ee PRA AEE EER a ee Bee 81 33 1 Absolute Punchons ces s 544 45 e e Fe aS ee EAH RO A 81 CONTENTS CONTENTS 3 6 a7 3 8 339 3 11 3 12 315 3 5 2 Function Argument Passing e e 81 IDA PUNcHon Return Values 2 2 24042085 4444 2654 654844 25 5 81 334 Function Stack Frame cee A Sk ek ee ee eG 82 Register Usage Conventions 6 56 a5 4 5 4 ee eee A eS 8 ROA 82 Operatgrs ga co EER A GHEE SERA ee e E 83 3TA Integral Promouon eeso AGS eR eS aa ee eG 83 3 7 2 Shitts applied to integral types ses ae rua ee oe BE 84 3 7 3 Division and modulus with integral types 85 o Sk eect ee tyes HG Bie ae By heh ee Ms ages e ae wert te i 85 3 8 1 Compilet senerated Psects ooo oops 85 Internipt Handling ME lt n ce ee e he eR ES A ewe eS 87 39 1 Interrapt Fonetions o esre eega rerea ee ee ee E 87 3 92 Interrupt amp Exception Types s oo ee eee eee et oS 87 3 9 3 Runtime Startup Callback Sequence lt 88 Mixing Cand Assembly Code ccoooa ee GN A ee ee oS 88 3 10 1 External Assembly Language Functions 89 3 10 2 Hasm endasm andasm e a e eere wae ea a E E 92 3 10 3 Accessing C objects from within Assembly Code 93 3 10 3 1 Accessing special function register names from assembler 94 3 10 4 Interaction between Assembly and C Code 94 S104 Absolute PSEC S 2 cc ks
216. e encoded within an instruction e Text is the string to convert to ASCII and embed For example STRING 1000 My favourite string will store the ASCII data for the string My favourite string including null terminator at ad dress 1000h Another example STRING 1000t34 My favourite string will store the same string with every byte in the string being trailed with the hex code 34h 175 Hexmate Linker and Utilities 5 14 1 18 STRPACK This option performs the same function as STRING but with two important differences Firstly only the lower seven bits from each character are stored Pairs of 7 bit characters are then concatenated and stored as a 14 bit word rather than in separate bytes This is usually only useful for devices where program space is addressed as 14 bit words The second difference is that STRING s t specifier is not applicable with STRPACK 176 Appendix A Library Functions The functions within the standard compiler library are listed in this chapter Each entry begins with the name of the function This is followed by information decomposed into the following categories Synopsis the C declaration of the function and the header file in which it is declared Description a narrative description of the function and its purpose Example an example of the use of the function It is usually a complete small program that illus trates the function Data types any special data types structures etc
217. e is hand written 475 conflicting FNCONF records Linker The linker has seen two conflicting FNCONF directives This directive should only be specified once and is included in the standard runtime startup code which is normally linked into every program 476 fixup overflow referencing location 0x 0x size value 0x Linker The linker was asked to relocate fixup an item that would not fit back into the space after relocation See the following error message 477 for more information 477 fixup overflow in expression location 0x 0x size value 0x Linker Fixup is the process conducted by the linker of replacing symbolic references to variables etc in an assembler instruction with an absolute value This takes place after positioning the psects program sections or blocks into the available memory on the target device Fixup overflow is when the value determined for a symbol is too large to fit within the allocated space within the assembler instruction For example if an assembler instruction has an 8 bit field to hold an address and the linker determines that the symbol that has been used to represent this address has the value 0x110 then clearly this value cannot be inserted into the instruction The causes for this can be many but hand written assembler code is always the first suspect Badly written C code can also generate assembler that ultimately generates fixup overflow errors Consider the foll
218. e original assem bly source code The assembler optimizer may also simpify some expression and remove some assembler directives from the listing file for clarity although they are processed in the usual way Provided the link stage has successfully concluded the listing file will be updated by the linker so that it contains absolute addresses and symbol values Thus you may use the assembler listing file to determine the position of and exact op codes corresponding to instructions 2 6 18 CALLGRAPH type Select callgraph type This option allows control over the type of callgraph produced in the map file Allowable suboptions include none to specify that no callgraph should be produced and full to indicate that the full callgraph be displayed in the map file In addition the suboption std can be specified to indicate that a shorter form without redundant information relating to ARG functions be produced or crit to indicate that only critical path information be displayed in the callgraph See also Sections 49 PICC32 Driver Option Descriptions PICC32 Command line Driver 2 6 19 CHECKSUM start end destination lt specs gt Calculate a checksum This option will perform a checksum over the address range specified and store the result at the destination address specified Additional specifications can be appended as a comma separated list to this option Such specifications are ywidth n select the byte width of the check
219. e usage of this option is FIND Findcode mMask Start End Align w t Title where e Findcode is the hexadecimal code sequence to search for and is entered in little endian byte order e Mask is optional It allows a bit mask over the Findcode value and is entered in little endian byte order e Start and End limit the address range to search through e Align is optional It specifies that a code sequence can only match if it begins on an address which is a multiple of this value w if present will cause hexmate to issue a warning whenever the code sequence is detected e Title is optional It allows a title to be given to this code sequence Defining a title will make log reports and messages more descriptive and more readable A title will not affect the actual search results TUTORIAL Let s look at some examples The option F IND 3412 0 7FFF 2w will detect the code sequence 1234h when aligned on a 2 two byte address boundary between 0h and 7FFFh w indicates that a warning will be issued each time this sequence is found Another example FIND 3412M0F00 0 7FFF 2wt ADDXY is same as last example but the code sequence being matched is masked with 000Fh so hexmate will search for 123xh If a byte mask is used is must be of equal byte width to the opcode it is applied to Any messaging or reports generated by hexmate will refer to this opcode by the name ADDXY as this was the title defined for this search If hexmate i
220. eatures HI TECH C PRO for the PIC32 MCU Family supports a number of special features and extensions to the C language which are designed to ease the task of producing ROM based applications This chapter documents the compiler options and special language features which are specific to the Microchip PIC 32 family of processors 3 1 ANSI Standard Issues 3 1 1 Divergence from the ANSI C Standard HI TECH C PRO for the PIC32 MCU Family does not diverge from the ANSI C standard except as noted below Function recursion is supported 3 1 2 Implementation defined behaviour Certain sections of the ANSI standard have implementation defined behaviour This means that the exact behaviour of some C code can vary from compiler to compiler Throughout this manual are sections describing how the HI TECH C PRO for the PIC32 MCU Family compiler behaves in such situations 3 1 3 Non ANSI Operations HI TECH C PRO for the PIC32 MCU Familycan detect specific sequences of portable ANSI C code that implicitly implements a rotate operation The C language only specifies a left and right shift 65 Processor related Features C Language Features operator but no rotate operator The code generator encodes matching sequences using assembly rotate instructions where possible The code sequence to implement a rotate right by 1 bit looks like var var gt gt 1 var lt lt 7 where var must be an unsigned char or var var gt gt 1 var lt
221. ebugger that will be used ECHO Echo command line before processing RFORMAT lt format gt Format error message strings to the given style Sets the maximun number of errors displayed 31 211 mea Lu LL opcode Fill unused program memory R RRORS number I Q TOPTION app file Get the command line options for the named applica tion HELP lt option gt Display the compiler s command line options IDE ide Configure the compiler for use by the named IDE INTERRUPTS subopt ion lt subopt Specify the Interrupts scheme continued PICC32 Command line Options Option Meaning ISA lt t ype gt Specify the Instruction Set Architecture LANG language Specify language for compiler messages MAPFILE lt file gt Generates a map file MEMMAP f ile Display memory summary information for the map file MSGDISABLE messagelist Disable warning messages MSGFORMAT lt format gt Format general message strings to the given style NODEL Do not remove temporary files generated by the com piler NOEXEC Go through the motions of compiling without actually compiling OBJDIR path Specify intermediate files directory OPT lt t ype gt Enable general compiler optimizations OUTDIR path Specify output files directory OUTPUT t ype Generate output file type PA
222. ections and for more information on these functions Critical path callgraph The Cc option only include the critical paths of the call graph A function call that is marked with a in a full call graph is on a critical path and only these calls are included when the Cc option is used See Section for more information on critical paths No callgraph The Cn option removes the call graph information from the map file 5 7 4 Cpsect class This option will allow a psect to be associated with a specific class Normally this is not required on the command line since classes are specified in object files 141 Operation Linker and Utilities 5 7 5 Dclass delta This option allows the delta value for psects that are members of the specified class to be defined The delta value should be a number and represents the number of bytes per addressable unit of objects within the psects Most psects do not need this option as they are defined with a delta value 5 7 6 Dsymfile Use this option to produce an old style symbol file An old style symbol file is an ASCH file where each line has the link address of the symbol followed by the symbol name 5 7 7 Eerrfile Error messages from the linker are written to standard error file handle 2 Under DOS there is no convenient way to redirect this to a file the compiler drivers will redirect standard error if standard output is redirected This option will make the linker write all err
223. ective s PAD option must be a non zero positive integer 871 argument to space psect flag must specify a positive constant Assembler The parameter to the PSECT assembler directive s space option must be a positive constant number e g PSECT text class CODE space 1 space values start at zero 386 Error and Warning Messages 872 psect flag space redefined Assembler The space flag to the PSECT assembler directive is different from a previous PSECT directive e g psect spdata class RAM space 0 elsewhere psect spdata class RAM space 1 875 bad character constant in expression Assembler Optimizer The character constant was expected to consist of only one character but was found to be greater than one character or none at all An assembler specific example mov r0 12 112 specifies two characters 876 syntax error Assembler Optimiser A syntax error has been detected This could be caused a number of things 877 yace stack overflow Assembler This is an internal compiler error Contact HI TECH Software technical support with details 878 S option used ignored Driver The indicated assembly file has been supplied to the driver in conjunction with the S option The driver really has nothing to do since the file is already an assembly file 880 invalid number of parameters Use HELP for help Driver Improper command line usage of the of the compiler
224. ector to point to This must be used within the appropriate interrupt routine Example void interrupt foo void SETVECTOR 3 foo void main void See Also Return Value Note This should be used in conjuction with the interrupt ram option 246 Library Functions SIN Synopsis include lt math h gt double sin double f Description This function returns the sine function of its argument Example include lt math h gt include lt stdio h gt define C 3 141592 180 0 void main void double i for i 0 i lt 180 0 i 10 printf sin 3 0f Sf n i sin i C printf cos 3 0f Sf n i cos i C See Also cos tan asin acos atan atan2 Return Value Sine vale of f 247 Library Functions SQRT Synopsis include lt math h gt double sqrt double f Description The function sqrt implements a square root routine using Newton s approximation Example include lt math h gt include lt stdio h gt void main void double i for i 0 i lt 20 0 i 1 0 o printf square root of 1f f n i sqrt i See Also exp Return Value Returns the value of the square root Note A domain error occurs if the argument is negative 248 Library Functions SRAND Synopsis include lt stdlib h gt void srand unsigned int seed Description The srand function in
225. ed in a P or A option to the linker It has been linked at the end of the program which is probably not where you wanted it 528 no start record entry point defaults to zero Linker None of the object files passed to the linker contained a start record The start address of the program has been set to zero This may be harmless but it is recommended that you define a start address in your startup module by using the END directive 529 usage objtohex Ssymfile object file hex file Objtohex Improper usage of the command line tool objtohex If you are invoking objtohex directly then please refer to Section 5 11 for more details Otherwise this may be an internal compiler error and you should contact HI TECH Software technical support with details 593 can t find 0x words 0x withtotal for psect in segment Linker See error 491 on Page 594 undefined symbol Linker The symbol following is undefined at link time This could be due to spelling error or failure to link an appropriate module 595 undefined symbols Linker A list of symbols follows that were undefined at link time These errors could be due to spelling error or failure to link an appropriate module 360 Error and Warning Messages 596 segment overlaps segment Linker The named segments have overlapping code or data Check the addresses being assigned by the P linker option 599 No psect c
226. efine BIG tendif 121 expression stack overflow at operator Preprocessor Expressions in if lines are evaluated using a stack with a size of 128 It is possible for very complex expressions to overflow this Simplify the expression 122 unbalanced parenthesis at operator Preprocessor The evaluation of a if expression found mismatched parentheses Check the expression for correct parenthesisation e g if A B oops a missing I think define ADDED endif 123 misplaced or previous operator is Preprocessor A colon operator has been encountered in a if expression that does not match up with a corre sponding operator e g if XXX YYY did you mean if COND XXX YYY 124 illegal character in if Preprocessor There is a character in a if expression that has no business being there Valid characters are the letters digits and those comprising the acceptable operators e g if YYY what are these characters doing here int m endif 292 Error and Warning Messages 125 illegal character decimal in if Preprocessor There is a non printable character in a if expression that has no business being there Valid char acters are the letters digits and those comprising the acceptable operators e g Hif SYYY what is this control characters doing here int m endif 126 strings can t be used in if Preprocessor The pr
227. emory but clearly the address Ox1FC exceeds this size Maybe the instruction should have been written as movwf _foo amp 0ffh which masks out the top bits of the address containing the bank information If the assembler instruction that caused this error was generated by the compiler in the assem bler list file look back up the file from the instruction at fault to determine which C statement has generated this instruction You will then need to examine the C code for possible errors incorrectly qualified pointers are an common trigger 478 range check failed location 0x 0x value 0x gt limit 0x Linker This is an internal compiler error Contact HI TECH Software technical support with details 479 circular indirect definition of symbol Linker The specified symbol has been equated to an external symbol which in turn has been equated to the first symbol 352 Error and Warning Messages 480 function signatures do not match 0x 0x Linker The specified function has different signatures in different modules This means it has been declared differently e g it may have been prototyped in one module and not another Check what declarations for the function are visible in the two modules specified and make sure they are compatible e g extern int get_value int in and in another module this is different to the declaration int get_value int in char type 481 co
228. ength of strings in this module 306 can t allocate bytes of memory for Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 307 too many qualifier names Parser This is an internal compiler error Contact HI TECH Software technical support with details 323 Error and Warning Messages 308 too many case labels in switch Code Generator There are too many case labels in this switch statement The maximum allowable number of case labels in any one switch statement is 511 309 too many symbols Assembler There are too many symbols for the assembler s symbol table Reduce the number of symbols in your program 310 expected Parser A closing square bracket was expected in an array declaration or an expression using an array index e g process carray idx oops should be process carray idx 311 closing quote expected Parser A closing quote was expected for the indicated string 312 expected Parser The indicated token was expected by the parser 313 function body expected Parser Where a function declaration is encountered with K amp R style arguments i e argument names but no types inside the parentheses a function body is expected to follow e g the function block must follow not a semicolon int get_value a b 314 expected Parser A semicolon is missing from a statement A close brace o
229. eprocessor does not allow the use of strings in if expressions e g no string operations allowed by the preprocessor if MESSAGE gt hello define DEBUG endif 127 bad syntax for defined in el if Preprocessor The defined pseudo function in a preprocessor expression requires its argument to be a single name The name must start with a letter and should be enclosed in parentheses e g oops defined expects a name not an expression if defined a amp b input read endif 128 illegal operator in if Preprocessor A if expression has an illegal operator Check for correct syntax e g if FOO 6 oops should that be if FOO 5 129 unexpected in if Preprocessor The backslash is incorrect in the if statement e g if FOO 34 define BIG Hendif 293 Error and Warning Messages 130 unknown type in el if sizeof Preprocessor An unknown type was used in a preprocessor sizeof The preprocessor can only evaluate sizeof with basic types or pointers to basic types e g Hif sizeof unt 2 should be if sizeof int 2 i OxFFFF fendif 131 illegal type combination in el if sizeof Preprocessor The preprocessor found an illegal type combination in the argument to sizeof in a if expres sion e g To sign or not to sign that is the error if sizeof signed unsigned int 2 i OxFFFF fendif 132 no ty
230. er and Utilities 5 8 Invoking the Linker The linker is called HLINK and normally resides in the BIN subdirectory of the compiler installation directory It may be invoked with no arguments in which case it will prompt for input from standard input If the standard input is a file no prompts will be printed This manner of invocation is generally useful if the number of arguments to HLINK is large Even if the list of files is too long to fit on one line continuation lines may be included by leaving a backslash at the end of the preceding line In this fashion HLINK commands of almost unlimited length may be issued For example a link command file called x 1nk and containing the following text Z OX OBJ MX MAP Ptext 0 data 0 bss nvram bss X OBJ Y OBJ Z OBJ C HT Z80 LIB Z80 SC LIB may be passed to the linker by one of the following hlink x 1nk hlink lt x 1nk 5 9 Map Files The map file contains information relating to the relocation of psects and the addresses assigned to symbols within those psects 5 9 1 Generation If compilation is being performed via HLTIDE a map file is generated by default without you having to adjust the compiler options If you are using the driver from the command line then you ll need to use the M option see Section 2 6 8 Map files are produced by the linker If the compilation process is stopped before the linker is executed then no map file is produced The linker will still
231. ernal compiler error Contact HI TECH Software technical support with details 710 bad U usage Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 711 bad how in expand Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 712 can t generate code for this expression Code Generator This error indicates that a C expression is too difficult for the code generator to actually compile For successful code generation the code generator must know how to compile an expression and there must be enough resources e g registers or temporary memory locations available Simplifying the expression e g using a temporary variable to hold an intermediate result may get around this message Contact HI TECH Support with details of this message This error may also be issued if the code being compiled is in some way unusual For example code which writes to a const qualified object is illegal and will result in warning messages but the code generator may unsuccessfully try to produce code to perform the write 713 bad initialization list Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 714 bad intermediate code Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 715 bad pragma Code Generator
232. ers Type qualifiers provide information regarding how an object may be used in addition to its type which defines it storage size and format HI TECH C PRO for the PIC32 MCU Family supports both ANSI qualifiers and additional special qualifiers which are useful for embedded applications and which take advantage of the PIC32 architecture 3 3 9 1 Const and Volatile Type Qualifiers HI TECH C PRO for the PIC32 MCU Family supports the use of the ANSI type qualifiers const and volatile The const type qualifier is used to tell the compiler that an object is read only and will not be modified If any attempt is made to modify an object declared const the compiler will issue a warning User defined objects declared const are placed in a special psect in the program space Obviously a const object must be initialised when it is declared as it cannot be assigned a value at any point at runtime For example const int version 3 The volatile type qualifier is used to tell the compiler that an object cannot be guaranteed to retain its value between successive accesses This prevents the optimizer from eliminating apparently redundant references to objects declared volatile because it may alter the behaviour of the program to do so All Input Output ports and any variables which may be modified by interrupt routines should be declared volatile for example volatile static sfr unsigned long PORTA 0xBF886010 Volatile objects may be accessed using
233. ers 74 SUBTITLE assembler control 135 SUMMARY option class 63 file 63 hex 63 mem 63 psect 63 switch pragma directive 101 switch type auto 102 direct table lookup 102 symbol files 35 44 Avocet format 147 enhanced 143 generating 143 local symbols in 147 old style 142 removing local symbols from 49 removing symbols from 146 source level 44 symbol tables 144 147 sorting 144 symbols assembler generated 118 global 138 156 linker defined 107 undefined 147 INDEX INDEX table read instruction 80 tan function 274 tanh function 196 temporary files 56 text psect 86 time function 275 TITLE assembler control 135 toascii function 277 tolower function 277 toupper function 277 translation unit 21 trunc function 278 type checking assembly routines 89 type qualifier 76 type qualifiers 75 typographic conventions 17 unamed structure members 74 ungetc function 279 280 ungetch function 281 unnamed psect 121 unsigned integer suffix 69 unused memory filling 165 utilities 137 utoa function 282 va_arg function 283 va_end function 283 va_start function 283 variable initialization 29 variables absolute 80 accessing from assembly 93 auto 79 char types 71 floating point types 72 int types 71 local 79 persistent 86 static 79 unique length of 47 verbose 49 version number 63 volatile qualifier 75 116 vscanf function 242 warning level 63
234. ers are 4 bytes wide For pointer that are accessing const objects the address contained within the pointer is an offset into the psect used to store the const data For programs defining less than 64 kbytes of const data this data is placed into a psect called const for larger const data amounts the psect is called constfar Any hand written assembler code or C code that writes to the table pointer SFRs di 78 C Language Features Storage Class and Object Placement rectly must ensure that the contents of any non active table registers are preserved Saving both TBLPTRH and TBLPTRU will ensure that this requirement is met 3 3 11 2 Function Pointers Function pointers can be defined to indirectly call functions or routines in the program space The size of these pointers are 32 bits wide The addresses for all code labels are shown in the map file as an untruncated 4 byte address 3 4 Storage Class and Object Placement Objects are positioned in different memory areas dependant on their storage class and declaration This is discussed in the following sections 3 4 1 Local Variables A local variable is one which only has scope within the block in which it was defined That is it may only be referenced within that block C supports two classes of local variables in functions auto variables which are normally allocated in the function s auto variable block and static variables which are always given a fixed memory location an
235. es int process int input 350 unused from line Parser The indicated object was never used in the function or module being compiled Either this object is redundant or the code that was meant to use it was excluded from compilation or misspelt the name of the object Note that the symbols rcsid and sccsid are never reported as being unused 352 float parameter coerced to double Parser Where a non prototyped function has a parameter declared as float the compiler converts this into a double float This is because the default C type conversion conventions provide that when a floating point number is passed to a non prototyped function it will be converted to double It is important that the function declaration be consistent with this convention e g double inc_flt f f will be converted to double float f warning flagged here return f 2 353 sizeof external array is zero Parser The size of an external array evaluates to zero This is probably due to the array not having an explicit dimension in the extern declaration 354 possible pointer truncation Parser A pointer qualified far has been assigned to a default pointer or a pointer qualified near or a default pointer has been assigned to a pointer qualified near This may result in truncation of the pointer and loss of information depending on the memory model in use 355 implicit signed to unsigned conversion Parser
236. es sion e g void run void step return 1 either run should not be void or remove the 1 305 Error and Warning Messages 205 integral type required Parser This operator requires operands that are of integral type only 206 illegal use of void expression Parser A void expression has no value and therefore you can t use it anywhere an expression with a value is required e g as an operand to an arithmetic operator 207 simple type required for Parser A simple type i e not an array or structure is required as an operand to this operator 208 operands of not same type Parser The operands of this operator are of different pointer e g int ip char cp cp27 cp flag ip cp2 result of will be int or char Maybe you meant something like cp flag char ip cp2 209 type conflict Parser The operands of this operator are of incompatible types 210 bad size list Parser This is an internal compiler error Contact HI TECH Software technical support with details 211 taking sizeof bit is illegal Parser It is illegal to use the sizeof operator with the HI TECH C bit type When used against a type the sizeof operator gives the number of bytes required to store an object that type Therefore its usage with the bit type make no sense and is an illegal operation 306 Error and Warning Messages 212 missing number after pr
237. esent or a minus character to indicate that they should be excluded In the following sections angle brackets lt gt are used to indicate optional parts of the command See the HELP option Section 2 6 29 for more information about options and suboptions oe 9 2 6 1 C Compile to Object File The C option is used to halt compilation after generating a relocatable object file This option is frequently used when compiling assembly source files using a make utility Use of this option when only a subset of all the C source files in a project are being compiled will result in an error from the code generator See Section 2 2 2 for more information on generating and using intermediate files 2 6 2 Dmacro Define Macro The D option is used to define a preprocessor macro on the command line exactly as if it had been defined using a define directive in the source code This option may take one of two forms Dmacro which is equivalent to define macro 1 placed at the top of each module compiled using this option or Dmacro t ext which is equivalent to define macro text 42 PICC32 Command line Driver PICC32 Driver Option Descriptions where text is the textual substitution required Thus the command PICC32 CHIP 32MX360F512L Ddebug Dbuffers 10 test c will compile test c with macros defined exactly as if the C source code had included the directives define debug 1 define buffers 10 2 6 3
238. ess that is a multiple of 100h The size flag allows a maximum size to be specified for the psect e g size 100h This will be checked by the linker after psects have been combined from all modules The space flag is used to differentiate areas of memory which have overlapping addresses but which are distinct Psects which are positioned in program memory and data memory may have a different space value to indicate that the program space address zero for example is a different location to the data memory address zero Devices which use banked RAM data memory typically have the same space value as their full addresses including bank information are unique The with flag allows a psect to be placed in the same page with a specified psect For example with text will specify that this psect should be placed in the same page as the text psect Some examples of the use of the PSECT directive follow PSECT fred PSECT bill size 100h global PSECT joh abs ovrld class CODE delta 2 4 3 10 4 ORG The ORG directive changes the value of the location counter within the current psect This means that the addresses set with ORG are relative to the base address of the psect which is not determined until link time 124 Macro Assembler HI TECH C Assembly Language Table 4 9 psect isa flag suboptions Suboption Meaning none default Indicates that the psect contains no executable assembly code of any ISA This option is usual
239. f values 0 val_cmp if vp printf Item fred was not found n else printf Item fred has value d n vp gt value See Also qsort Return Value A pointer to the matched array element if there is more than one matching element any of these may be returned If no match is found a null pointer is returned Note The comparison function must have the correct prototype 191 Library Functions CEIL Synopsis include lt math h gt double ceil double f Description This routine returns the smallest whole number not less than f Example include lt stdio h gt include lt math h gt void main void double j scanf S1f 3 printf The ceiling of 1f is lf n j ceil j 192 Library Functions CGETS Synopsis include lt conio h gt char cgets char s Description The cgets function will read one line of input from the console into the buffer passed as an ar gument It does so by repeated calls to getche As characters are read they are buffered with backspace deleting the previously typed character and ctrl U deleting the entire line typed so far Other characters are placed in the buffer with a carriage return or line feed newline terminating the function The collected string is null terminated Example include lt conio h gt include lt string h gt char buffer 80 void main void for cgets buffer
240. f you are invoking objtohex directly then see Section 5 11 for more details Otherwise this may be an internal compiler error and you should contact HI TECH Software technical support with details 409 bad argument to P Objtohex This option requires an integer argument in either base 8 10 or 16 If you are invoking objtohex directly then see Section 5 11 for more details Otherwise this may be an internal compiler error and you should contact HI TECH Software technical support with details 410 bad combination of options Objtohex The combination of options supplied to OBJTOHEX is invalid 412 text does not start at 0 Objtohex Code in some things must start at zero Here it doesn t 413 write error on Assembler Linker Cromwell A write error occurred on the named file This probably means you have run out of disk space 414 read error on Linker The linker encountered an error trying to read this file 415 text offset too low in COFF file Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 416 bad character in extended TEKHEX line Objtohex This is an internal compiler error Contact HI TECH Software technical support with details 417 seek error in Linker This is an internal compiler error Contact HI TECH Software technical support with details 342 Error and Warning Messages 418 image too big Objtohex
241. ficant bit of the result Left shifts lt lt operator signed or unsigned always clear the least significant bit of the result 3 7 3 Division and modulus with integral types The sign of the result of division with integers when either operand is negative is implementation specific 3 5 shows the expected sign of the result of the division of operand 1 with operand 2 when compiled with PICC 32 In the case where the second operand is zero division by zero the result will always be zero 3 8 Psects The compiler splits code and data objects into a number of standard program sections referred to as psects The HI TECH assembler allows an arbitrary number of named psects to be included in assembler code The linker will group all data for a particular psect into a single segment If you are using PICC32 to invoke the linker you don t need to worry about the in formation documented here except as background knowledge If you want to run the linker manually this is not recommended or write your own assembly language sub routines you should read this section carefully A psect can be created in assembly code by using the PSECT assembler directive see Section 4 3 10 3 3 8 1 Compiler generated Psects The code generator places code and data into psects with standard names which are subsequent positioned by the default linker options These psects are linked into KSEG1 internal boot flash internal program flash and internal RAM t
242. figures the number of bytes contained per address location If for example a device s program memory naturally used a 16 bit 2 byte word addressing format the option ADDRESSING 2 will configure hexmate to interpret all command line address fields as word addresses The affect of this setting is global and all hexmate options will now interpret addresses according to this setting This option will allow specification of addressing modes from one byte per address to four bytes per address 168 Linker and Utilities Hexmate 5 14 14 BREAK This option takes a comma separated list of addresses If any of these addresses are encountered in the hex file the current data record will conclude and a new data record will recommence from the nominated address This can be useful to use new data records to force a distinction between functionally different areas of program space Some hex file readers depend on this 5 14 15 CK The CK option is for calculating a checksum The usage of this option is CK start end destination toffset wWidth tCode gAlogithm where Start and End specify the address range that the checksum will be calculated over Destination is the address where to store the checksum result This value cannot be within the range of calculation Offset is an optional initial value to add to the checksum result Width is optional and specifies the byte width of the checksum result Results can be calculated for byte w
243. follow This specifies printf style format string checking for the function e g pragma printf_check what function is to be checked Maybe you meant something like pragma printf_check sprintf Pragmas for all the standard printf like function are already contained in lt stdio h gt 220 exponent expected Parser A floating point constant must have at least one digit after the e or E e g float f f 1 234e oops what is the exponent 221 hexadecimal digit expected Parser After 0x should follow at least one of the hex digits 0 9 and A F or a f e g a 0xg6 oops was that meant to be a 0xf6 222 binary digit expected Parser A binary digit was expected following the 0b format specifier e g i 0bf000 wooops f000 is not a base two value 223 digit out of range Parser Assembler Optimiser A digit in this number is out of range of the radix for the number e g using the digit 8 in an octal number or hex digits A F in a decimal number An octal number is denoted by the digit string commencing with a zero while a hex number starts with OX or Ox For example int a 058 leading 0 implies octal which has digits 0 7 308 Error and Warning Messages 224 illegal directive Parser An illegal preprocessor has been detected Likely a directive has been misspelt in your code somewhere 225 missing character in character constant Parser The char
244. follows GLOBAL _ foo Sw a3 _foo __gptr gp If the assembler is contained in a different module then the GLOBAL assembler directive should be used in the assembly code to make the symbol name available as above If the object is being accessed from in line assembly in another module then an extern declaration for the object can be made in the C code for example extern int foo This declaration will only take effect in the module if the object is also accessed from within C code If this is not the case then an in line GLOBAL assembler directive should be used Care should be taken if the object is defined in a bank other than 0 The address of a C object includes the bank information which must be stripped before the address can be used in most PIC32 instructions The exceptions are the movff and 1sfr instructions Failure to do this may result in fixup errors issued by the linker If in doubt as to writing assembler which access C objects write code in C which performs a similar task to what you intend to do and study the assembler listing file produced by the compiler C identifiers are assigned different symbols in the output assembly code so that an as sembly identifier cannot conflict with an identifier defined in C code If assembly pro grammers choose identifier names that do not begin with an underscore these identifiers will never conflict with C identifiers Importantly this implies that the assembly identi fier i and th
245. for hexadecimal Case in not important for any number or radix Decimal is default e g AENTRY 0 0FFh 1FF Did you forget the radix AENTRY 0 0FFh 1FFh 447 bad load address in A spec Linker The load address given in a A specification is invalid it should be a valid number in decimal octal or hexadecimal radix The radix is specified by a trailing O for octal or H for hex A leading 0x may also be used for hexadecimal Case in not important for any number or radix Decimal is default e g ACODE 0h 3fffh a000 Did you forget the radix ACODE 0h 3fffh a000h 448 bad repeat count in A spec Linker The repeat count given in a A specification is invalid e g AENTRY 0 0FFhxf Did you forget the radix AENTRY 0 0FFhxfh 449 syntax error in A spec Linker The A spec is invalid A valid A spec should be something like AROM 1000h 1FFFh 347 Error and Warning Messages 450 psect was never defined Linker Optimiser This psect has been listed in a P option but is not defined in any module within the program 451 bad psect origin format in P option Linker The origin format in a p option is not a validly formed decimal octal or hex number nor is it the name of an existing psect A hex number must have a trailing H e g pbss f000 Did you forget the radix pbss f000h 452 bad minimum address format in P option Linker The minimum address specification in the l
246. fore code generation of these files the compiler assembles any assembly source files to relocatable object files These object files together with any object files specified on the command line are scanned by the compiler driver and certain information from these files are collated and passed to the code generator Several actions are taken based on this information See Section 3 10 4 The driver instructs the code generator to preserve any C variables that map to symbols which are used but not defined in the assembly object code In line assembly is similarly scanned This allows variables to be defined in C code and only referenced in assembly code Normally such C variables would be removed as the code generator would consider them to be unused from the C perspective However in this case the C variables are automatically qualified as being volatile which is sufficient to prevent the code generator making this optimization The driver also takes note of any absolute psects viz use the abs and ovrld PSECT directive flags in the assembly object code The memory occupied by the psects is removed from the available memory ranges passes to the code generator and linker This information ensures that this memory is not allocated to any C resources 2 3 Runtime Files In addition to the input files specified on the command line by the user there are also compiler generated source files and pre compiled library files which might be compiled into
247. function in which the warning is located reproduced 39 Compiler Messages PICC32 Command line Driver the line of source code and highlighted the position at which the warning was first detected as well as show the actual warning message string The E option is now used and the compiler issues the same messages but in a new format as dictated by the E option Now environment variables are set and no other messaging driver options were specified so the default E format is used main c 12 362 redundant amp applied to array warning 492 attempt to position absolute psect text is illegal error Notice that now all message follow a more uniform format and are displayed on a single line The user now sets the environment variable HTC_WARN_FORMAT to be the following string Under Windows this can be performed via the Control Panel s System panel sa sn Sl SE s and the project recompiled The following output will be displayed parser 362 12 main c redundant amp applied to array 492 attempt to position absolute psect text is illegal error Notice that the format of the warning was changed but that of the error message was not The warning format now follows the specification of the environment variable The application name parser was substituted for the Sa placeholder the message number 362 substituted the n placeholder etc The option ERRFORMAT a n 1 f s is then added to the driver comm
248. fy an exact storage location The Scale of a psect indicates the number of address units per byte this is left blank if the scale is 1 and typically this will show 8 for psects that hold bit objects The Load address of psects that hold bits is used to display the link address converted into units of bytes rather than the load address TUTORIAL INTERPRETING THE PSECT LIST The following appears in a map file Name Link Load Length Selector Space Scale ext obj text 3A 3A 22 30 0 bss 4B 4B 10 4B 1 rbit 50 A 2 0 1 8 This indicates that one of the files that the linker processed was called ext obj This may have been derived from ext c or ext as This object file contained a text psect as well as psects called bss and rbit The psect text was linked at address 3A and bss at address 4B At first glance this seems to be a problem given that text is 22 words long however note that they are in different memory areas as indicated by the Space flag 0 for text and 1 for bss and so do not occupy the same memory The psect 151 Map Files Linker and Utilities rbit contains bit objects as indicated by its Scale value its name is a bit of a giveaway too Again at first glance there seems there could be an issue with rbit linked over the top of bss Their Space flags are the same but since rbit contains bit objects all the addresses shown are bit addresses as indicated by the Scale value of 8 Note that the Load address field of
249. gging a project that fails to work as expected If a multi step compilation is required the recommended compile sequence is as follows e Compile all modified C source files to p code files using the PASS1 driver option 24 PICC32 Command line Driver The Compilation Sequence e Compile all modified assembler source files to relocatable object files using the C driver option e Compile all p code and relocatable object files into a single output object file The final step not only involves the link stage but also code generation of all the p code files In effect the HI TECH C PRO for the PIC32 MCU Family version code generator performs some of the tasks normally performed by the linker Any user specified non standard libraries also need to be passed to the compiler during the final step This is the incremental build sequence used by HI TIDE TUTORIAL MULTI STEP COMPILATION The files in the previous example are to be compiled using a multi step compilation The following could be used PICC32 chip 32MX360F512L passl main c PICC32 chip 32MX360F512L passl io c PICC32 chip 32MX360F512L c mdef as PICC32 chip 32MX360F512L main pl io pl mdef obj sprt obj c_sb lpp a_sb If using a make system with incremental builds only those source files that have changed since the last build need the first compilation step performed again so not all of the first three steps need be executed If is important to note that
250. han zero 377 Error and Warning Messages 766 degenerate signed comparison Code Generator There is a comparison of a signed value with the most negative value possible for this type such that the comparison will always be true or false e g char c 1f c gt 128 will always be true because an 8 bit signed char has a maximum negative value of 128 767 constant truncated to bitfield width Code Generator A constant value is too large for a bitfield structure member on which it is operating e g struct INPUT unsigned a 3 unsigned b 5 input_grp input_grp a 0x13 13h to large for 3 bit wide object 768 constant relational expression Code Generator There is a relational expression that will always be true or false This may be because e g you are comparing an unsigned number with a negative value or comparing a variable with a value greater than the largest number it can represent e g unsigned int a if a 10 if a is unsigned how can it be 10 b 9 769 no space for macro definition Assembler The assembler has run out of memory 772 include files nested too deep Assembler Macro expansions and include file handling have filled up the assembler s internal stack The maxi mum number of open macros and include files is 30 378 Error and Warning Messages 773 macro expansions nested too deep Assembler Macro expansions in the assembler are nested
251. he PIC32 MCU Family compiler supports basic data types with 1 2 and 4 byte sizes All multi byte types follow least significant byte first format also known as little endian Word size values thus have the least significant byte at the lower address and double word size values have the least significant byte and least significant word at the lowest address Table 3 1 shows the data types and their corresponding size and arithmetic type 3 3 1 Radix Specifiers and Constants The format of integral constants specifies their radix HI TECH C PRO for the PIC32 MCU Fam ily supports the ANSI standard radix specifiers as well as ones which enables binary constants to specified in C code The format used to specify the radices are given in Table 3 2 The letters used to specify binary or hexadecimal radices are case insensitive as are the letters used to specify the hexadecimal digits 67 Supported Data Types and Variables C Language Features 68 Table 3 1 Basic data types Type Size bits Arithmetic Type bit 1 unsigned integer char 8 unsigned integer unsigned char 8 unsigned integer signed char 8 signed integer short 16 signed integer unsigned short 16 unsigned integer signed short 16 signed integer int 32 signed integer unsigned int 32 unsigned integer signed int 32 signed integer long 32 signed integer unsigned long 32 uns
252. he pragma will remain in force during compilation of the entire module The state of those warnings which have been disabled can preserved and recalled using the warning push and warning pop pragmas Pushes and pops can be nested to allow a large degree of control over the message behaviour TUTORIAL DISABLING A WARNING The following example shows the warning associated with 102 C Language Features Preprocessing qualifying an auto object being disabled number 348 void main void pragma warning disable 348 near int c pragma warning enable 348 etc int rv int a near int c etc which will issue only one warning associated with the second definition of the auto variable c Warning number 348 is disabled during parsing of the definition of the auto variable c inside the function main altst c 35 348 auto variable c should not be qualified warning This same affect would be observed using the following code void main void pragma warning push pragma warning disable 348 near int C pragma warning pop etc d int rv int a near int c etc Here the state of the messaging system is saved by the warning push pragma Warning 348 is disabled then after the source code which triggers the warning the state of the messaging system is retrieved by the use of the warning pop pragma 103 Linking Programs C Language Features The warning error wa
253. he warning will be suppressed This may also mean you have forgotten the amp address operator e g int ip int i ip i oops did you mean ip amp i If you do intend to use an expression like this then indicate that this is so by a cast ip int i 333 Error and Warning Messages 358 illegal conversion of pointer to integer Parser A pointer has been assigned to or otherwise converted to a integral type This will usually mean you have used the wrong variable but if this is genuinely what you want to do use a typecast to inform the compiler that you want the conversion and the warning will be suppressed This may also mean you have forgotten the dereference operator e g int ip ane Le i s ip oops did you mean i ip If you do intend to use an expression like this then indicate that this is so by a cast i int ip 359 illegal conversion between pointer types Parser A pointer of one type i e pointing to a particular kind of object has been converted into a pointer of a different type This will usually mean you have used the wrong variable but if this is genuinely what you want to do use a typecast to inform the compiler that you want the conversion and the warning will be suppressed e g long input char cp cp amp input is this correct This is common way of accessing bytes within a multi byte variable To indicate that this is the intended operat
254. hen loaded into the respective physical implementations 85 Psects C Language Features The compiler generated psects which are loaded in internal boot flash are init Runtime startup code which performs initialisation for example clearing the RAM powerup Used to load any user defined routine in powerup as config Used to store the configuration words reset Code to service the reset vector at OxBFC00000 and invoke the runtime startup code bootex Code to service the bootstrap exception vector at OxBFC00380 and invoke if provided the interrupt function to handle it The compiler generated psects which are placed in Internal program flash are textl6 Isa global psect used for MIPS16e executable code and library functions text32 Is a global psect used for MIPS32r2 executable code and library functions idata These psects contain the ROM image of any initialised variables These psects are copied into the data psects at startup strings This psect holds the program string literals table const These psects hold objects that are declared const and are within range of the pointer stored in register 30 a k a s8 or fp constfar These psects hold objects that are declared const and are out of range of the pointer stored in register 30 a k a s8 or fp vectors This psect holds the interrupt vector table The compiler generated psects which are loaded in internal RAM are bss These psects contain uninitialized global or stati
255. her parameters In this example the function expects the subsequent parameters to be pointers to char but note that the compiler is not aware of this and it is the programmers responsibility to ensure that correct arguments are supplied Example include lt stdio h gt include lt stdarg h gt void pf int a 283 Library Functions va_list ap va_start ap a while a puts va_arg ap char va_end ap void main void pf 3 Line 1 lines2 Mine 30 284 Library Functions XTOI Synopsis include lt stdlib h gt unsigned xtoi const char s Description The xtoi function scans the character string passed to it skipping leading blanks reading an optional sign and converts an ASCII representation of a hexadecimal number to an integer Example include lt stdlib h gt include lt stdio h gt void main void char buf 80 int i gets buf i xtoi buf printf Read s converted to x n buf i See Also atoi Return Value A signed integer If no number is found in the string zero will be returned 285 Library Functions 286 Appendix B Error and Warning Messages This chapter lists most error warning and advisory messages from all HI TECH C compilers with an explanation of each message Most messages have been assigned a unique number which appears in brackets before each message in this chapter and which is als
256. hex constant Assembler A token which could either be interpreted as a symbol or a hexadecimal value does not match any previously defined symbol and so will be interpreted as the latter Use a leading zero to avoid the ambiguity or use an alternate radix sepcifier such as 0x For example mov a F h is this the symbol F7h or the hex number 0xF7 1257 local variable is used but never given a value Code Generator An auto variable has been defined and used in an expression but it has not been assigned a value in the C code before its first use Auto variables are not cleared on startup and their initial value is undefined For example void main void double src out out sin src oops what value was in src 1259 can t optimize for both speed and space Driver The driver has been given contradictory options of compile for speed and compile for space e g opt speed space 410 Error and Warning Messages 1260 macro redefined Assembler More than one definition for a macro with the same name has been encountered e g MACRO fin ret ENDM MACRO fin oops was this meant to be a different macro reti ENDM 1261 string constant required Assembler A string argument is required with the DS or DSU directive e g DS ONE oops did you mean DS ONE 1264 unsafe pointer conversion Code Generator A pointer to one kind of structure has been converted to another
257. hey cover Table 2 14 shows what summary types are available 2 6 55 TIME Report time taken for each phase of build process Adding TIME when building generate a summary which shows how much time each stage of the build process took to complete 2 6 56 VER Display The Compiler s Version Information The VER option will display what version of the compiler is running 2 6 57 WARN 1level Set Warning Level The WARN option is used to set the compiler warning level Allowable warning levels range from 9 to 9 The warning level determines how pedantic the compiler is about dubious type conversions 63 PICC32 Driver Option Descriptions PICC32 Command line Driver and constructs The higher the warning level the more important the warning message The default warning level is 0 and will allow all normal warning messages Use this option with care as some warning messages indicate code that is likely to fail during execution or compromise portability Warning message can be individually disabled with the MSGDISABLE option see 2 6 35 See also Section 2 5 for full information on the compiler s messaging system 2 6 58 WARNFORMAT format Set Warning Message Format This option sets the format of warning messages produced by the compiler See Section 2 5 4 for more information on this option For full information on the compiler s messaging system see Section 2 5 64 Chapter 3 C Language F
258. idths of 1 to 4 bytes If a positive width is requested the result will be stored in big endian byte order A negative width will cause the result to be stored in little endian byte order If the width is left unspecified the result will be 2 bytes wide and stored in little endian byte order Code is a hexadecimal code that will trail each byte in the checksum result This can allow each byte of the checksum result to be embedded within an instruction Algorithm is an integer to select which hexmate algorithm to use to calculate the checksum result A list of selectable algorithms are given in Table 5 10 If unspecified the default checksum algorithm used is 8 bit addition A typical example of the use of the checksum option is CK 0 1FFF 2FFE 2100w2 This will calculate a checksum over the range 0 1FFFh and program the checksum result at address 2FFEh checksum value will apply an initial offset of 2100h The result will be two bytes wide 169 Hexmate Linker and Utilities Table 5 10 Hexmate Checksum Algorithm Selection Selector Algorithm description 4 Subtraction of 32 bit values from initial value 3 Subtraction of 24 bit values from initial value 2 Subtraction of 16 bit values from initial value 1 Subtraction of 8 bit values from initial value 1 Addition of 8 bit values from initial value 2 Addition of 16 bit values from initial value 3 Addition of 24 bit values from initial value 4 7 8
259. ied 5 12 3 Llen Specify the length of the paper on which the listing is to be produced e g if the listing is to be printed on 55 line paper you would use a L55 option The default is 66 lines 5 12 4 Ooutfile Allows specification of the output file name By default the listing will be written to the standard output and may be redirected in the usual manner Alternatively out file may be specified as the output file name 512 5 Pwidth This option allows the specification of the width to which the listing is to be formatted e g P132 will format the listing for a 132 column printer The default is 80 columns 5 12 6 Sstoplist The S option should have as its argument the name of a file containing a list of symbols not to be listed in the cross reference Multiple stoplists may be supplied with multiple S options 161 Cromwell Linker and Utilities Table 5 6 CROMWELL format types Key Format cod Bytecraft COD file coff COFF file format elf ELF DWARF file eomf51 Extended OMF 51 format hitech HI TECH Software format icoff ICOFF file format ihex Intel HEX file format mcoff Microchip COFF file format omf51 OME 51 file format pe P amp E file format s19 Motorola HEX file format 5 12 7 Xprefix The X option allows the exclusion of symbols from the listing based on a prefix given as argument to X For example if it was desired to exclude all symbols st
260. if preprocessor ifndef FLAG symbol not defined jump endif include include text file into source include lt stdio h gt include project h line specify line number and filename line 3 final for listing nn where nn is a number short for 20 line nn pragma compiler specific options 3 11 4 undef undefines preprocessor symbol undef FLAG warning generate a warning message warning Length not set 99 Preprocessing C Language Features Table 3 8 Pragma directives Directive Meaning Example jis Enable JIS character handling in pragma jis strings nojis Disable JIS character handling de pragma nojis fault printf_check Enable printf style format string pragma checking printf_check printf const regsused Specify registers which are used in pragma regsused r4 an interrupt switch Specify code generation for switch pragma switch direct statements warning Control messaging parameters pragma warning disable 299 407 3 11 4 Pragma Directives There are certain compile time directives that can be used to modify the behaviour of the compiler These are implemented through the use of the ANSI standard pragma facility The format of a pragma is pragma keyword options where keyword is one of a set of keywords some of which are followed by certain options A list of the keywords is given in Table 3 8 Those keywords not discussed elsewhere are detailed below 3 11
261. igned integer signed long 32 signed integer float 32 real double 32 real Table 3 2 Radix formats Radix Format Example binary Obnumber or 0Bnumber 0b10011010 octal Onumber 0763 decimal number 129 hexadecimal 0xnumber or 0Xnumber 0x2F C Language Features Supported Data Types and Variables Any integral constant will have a type which is the smallest type that can hold the value without overflow The suffix 1 or L may be used with the constant to indicate that it must be assigned either a signed long or unsigned long type and the suffix u or U may be used with the constant to indicate that it must be assigned an unsigned type and both 1 or L and u or U may be used to indicate unsigned long int type Floating point constants have double type unless suffixed by f or F in which case it is a float constant The suffixes 1 or L specify a long double type which is considered an identical type to double by HI TECH C PRO for the PIC32 MCU Family Character constants are enclosed by single quote characters for example a A character constant has char type Multi byte character constants are not supported String constants or string literals are enclosed by double quote characters for example hello world The type of string constants is const char and the strings are stored in the program memory Assigning a string constant to a non const char pointer will generate a warning from the compiler For example char cp
262. ile what condition is true if i gt 5 error flagged here end 320 expected Parser A colon is missing after a case label or after the keyword default This often occurs when a semicolon is accidentally typed instead of a colon e g switch input case 0 oops that should have been case 0 state NEW 321 label identifier expected Parser An identifier denoting a label must appear after goto e g if a goto 20 this is not BASIC a valid C label must follow a goto 322 enum tag or expected Parser After the keyword enum must come either an identifier that is or will be defined as an enum tag or an opening brace e g enum 1 2 should be e g enum one 1 two 323 struct union tag or expected Parser An identifier denoting a structure or union or an opening brace must follow a struct or union keyword e g struct int a this is not how you define a structure You might mean something like struct int a my_struct 326 Error and Warning Messages 324 too many arguments for printf style format string Parser There are too many arguments for this format string This is harmless but may represent an incorrect format string e g oops missed a placeholder printf Sd d low high median 325 error in printf style format string Parser There is an error in the format string here The string has been inter
263. ilename was converted to lower case Preprocessor The include file name had to be converted to lowercase before it could be opened e g include lt STDIO H gt oops should be include lt stdio h gt 165 include filename does not match actual name check upper lower case Prepro cessor In Windows versions this means the file to be included actually exists and is spelt the same way as the include filename however the case of each does not exactly match For example specifying include code c will include Code c if it is found In Linux versions this warning could occur if the file wasn t found 166 too few values specified with option Preprocessor The list of values to the preprocessor CPP S option is incomplete This should not happen if the preprocessor is being invoked by the compiler driver The values passes to this option represent the sizes of char short int long float and double types 167 too many values specified with S option unused Preprocessor There were too many values supplied to the S preprocessor option See the Error Message s too few values specified in on page 168 unknown option Any This option given to the component which caused the error is not recognized 169 strange character after Preprocessor There is an unexpected character after 298 Error and Warning Messages 170 symbol in undef was never defi
264. ilure Preprocessor The argument to a preprocessor assert directive has evaluated to zero This is a programmer induced error assert SIZE size should never be 4 105 no asm before endasm Preprocessor A endasm operator has been encountered but there was no previous matching asm e g void cleardog void clrwdt endasm in line assembler ends here only where did it begin 106 nested asm directives Preprocessor It is not legal to nest asm directives Check for a missing or misspelt endasm directive e g tasm move r0 0aah asm previous asm must be closed before opening another sleep endasm 107 illegal directive Preprocessor Parser The compiler does not understand the directive It is probably a misspelling of a pre processor directive e g indef DEBUG oops that should be undef DEBUG 289 Error and Warning Messages 108 if n def without an argument Preprocessor The preprocessor directives if ifdef and ifndef must have an argument The argument to if should be an expression while the argument to ifdef or ifndef should be a single name e g if oops no argument to check output 10 else output 20 endif 109 include syntax error Preprocessor The syntax of the filename argument to include is invalid The argument to include must be a valid file name either enclosed in double quotes or angle brackets lt
265. imum number of bytes per data record A valid length is between 1 and 16 with 16 being the default TUTORIAL Consider this case A bootloader trying to download an INHX32 file fails succeed because it cannot process the extended address records which are part of the INHX32 standard You know that this bootloader can only program data addressed within the range O to 64k and that any data in the hex file outside of this range can be safely 172 Linker and Utilities Hexmate Table 5 11 INHX types used in FORMAT option Type Description INHX8M Cannot program addresses beyond 64K INHX32 Can program addresses beyond 64K with extended linear address records INHX032 INHX32 with initialization of upper address to zero disregarded In this case by generating the hex file in INHX8M format the operation might succeed The hexmate option to do this would be FORMAT INHX8M Now consider this What if the same bootloader also required every data record to contain eight bytes of data no more no less This is possible by combining FORMAT with FILL Appropriate use of FILL can ensure that there are no gaps in the data for the address range being programmed This will satisfy the minimum data length requirement To set the maximum length of data records to eight bytes just modify the previous option to become FORMAT INHX8M 8 The possible types that are supported by this option are listed in Table 5 11 Note that I
266. ind an area of free memory large enough to accommodate one of the psects The error message indicates the name of the psect that the linker was attempting to position and the segment name which is typically the name of a class which is defined with a linker A option Section 3 8 1 lists each compiler generated psect and what it contains Typically psect names which are or include text relate to program code Names such as bss or data refer to variable blocks This error can be due to two reasons First the size of the program or the program s data has exceeded the total amount of space on the selected device In other words some part of your device s memory has completely filled If this is the case then the size of the specified psect must be reduced The second cause of this message is when the total amount of memory needed by the psect being positioned is sufficient but that this memory is fragmented in such a way that the largest contiguous block is too small to accommodate the psect The linker is unable to split psects in this situation That is the linker cannot place part of a psect at one location and part somewhere else Thus the linker must be able to find a contiguous block of memory large enough for every psect If this is the cause of the error then the psect must be split into smaller psects if possible To find out what memory is still available generate and look in the map file see Section 2 6 8 for information on how to ge
267. inker s p option is badly formatted e g pbss data f000 Did you forget the radix pbss data f000h 453 missing number after in P option Linker The operator in a p option for rounding boundaries must have a number after it 454 link and load address can t both be set to in P option Linker The link and load address of a psect have both been specified with a dot character Only one of these addresses may be specified in this manner e g Pmypsect 1000hk Pmypsect 1000h Both of these options are valid and equivalent however the following usage is ambiguous Pmypsect What is the link or load address of this psect 348 Error and Warning Messages 455 psect not relocated on 0x byte boundary Linker This psect is not relocated on the required boundary Check the relocatability of the psect and correct the p option if necessary 456 psect not loaded on 0x boundary Linker This psect has a relocatability requirement that is not met by the load address given in a p option For example if a psect must be on a 4K byte boundary you could not start it at 100H 459 remove failed error xstrip The creation of the output file failed when removing an interemediate file 460 rename failed error xstrip The creation of the output file failed when renaming an interemediate file 461 can t create file Assembler Code Generator This is
268. internal compiler error Contact HI TECH Software technical support with details 295 expression too complex Parser This expression has caused overflow of the compiler s internal stack and should be re arranged or split into two expressions 296 out of memory Objtohex This could be an internal compiler error Contact HI TECH Software technical support with details 297 bad argument to tysize Parser This is an internal compiler error Contact HI TECH Software technical support with details 322 Error and Warning Messages 298 end of file in asm Preprocessor An end of file has been encountered inside a asm block This probably means the endasm is missing or misspelt e g asm mov r0 55 mov rl r0 oops where is the endasm 300 unexpected end of file Parser An end of file in a C module was encountered unexpectedly e g void main void init run is that it What about the close brace 301 end of file on string file Parser This is an internal compiler error Contact HI TECH Software technical support with details 302 can t reopen Parser This is an internal compiler error Contact HI TECH Software technical support with details 303 can t allocate bytes of memory line Parser The parser was unable to allocate memory for the longest string encountered as it attempts to sort and merge strings Try reducing the number or l
269. ion of the program use a cast cp char amp input that s better This warning may also occur when converting between pointers to objects which have the same type but which have different qualifiers e g char cp yes but what sort of characters cp I am a string of characters If the default type for string literals is const char then this warning is quite valid This should be written const char cp cp I am a string of characters that s better Omitting a qualifier from a pointer type is often disastrous but almost certainly not what you intend 334 Error and Warning Messages 360 array index out of bounds Parser An array is being indexed with a constant value that is less than zero or greater than or equal to the number of elements in the array This warning will not be issued when accessing an array element via a pointer variable e g int i ip input 10 i input 2 oops this element doesn t exist ip amp input 5 i ip 21 this is okay 361 function declared implicit int Parser Where the compiler encounters a function call of a function whose name is presently undefined the compiler will automatically declare the function to be of type int with unspecified K amp R style parameters If a definition of the function is subsequently encountered it is possible that its type and arguments will be different from the earlier imp
270. iplier PLL input divide by 2 Table 2 2 Default configuration settings 2 3 2 6 Default Configuration Words RUNTIME config With this runtime sub option enabled the driver will check to ensure that the config words at the top of boot flash have been programmed using the __CONFIG macro defined in lt pic32 h gt If any of these words have not be programmed the driver will do so with default settings as per Table 2 2 These settings will configure the device to operate at maximum speed and for debugging 2 3 2 7 Memory Performance RUNTIME perform This runtime option configures the device to operate for optimal performance This option takes only one argument separated by a colon the nominated operating frequency in Hz This argument is optional and if it is missing the driver will assume that you intend to operate the device at maximum frequency as per the configuration settings in Table 2 2 Using either the maximum or nominated frequency the driver will initialise the device with the following settings e the appropriate PFM wait states assuming a flash speed of 30MHz e disable DRM wait states 32 PICC32 Command line Driver Runtime Files e enable instruction caching and e enable predictive prefetch cache on all regions 2 3 3 The Powerup Routine Some hardware configurations require special initialization often within the first few instruction cycles after reset To achieve this there is
271. ironment variables Variable Effect HTC_MSG_FORMAT All advisory messages HTC_WARN_FORMAT All warning messages HTC_ERR_FORMAT All error and fatal error messages Table 2 5 Messaging placeholders Placeholder Replacement Sa application name SC column number SE filename 1 line number sn message number s message string from MDF to specify the placeholders as DOS interprets a single percent character as an argument and will not pass this on to the compiler For example ERRFORMAT file f line 1 The message environment variables in turn may be overridden by the driver options MSGFORMAT WARNFORMAT and ERRFORMAT see Sections 2 6 25 2 6 36 and 2 6 58 These options take a string as their argument The option strings are formatted and can use the same placeholders as their variable counterparts TUT RIAL CHANGING MESSAGE FORMATS A project is compiled but produces a warning from the parser and an error from the linker By default the following messages are displayed when compiling main c main 17 ip amp b 362 redundant amp applied to array warning 492 attempt to position absolute psect text is illegal Notice that the format of the messages from the parser and linker differ since the parser is able to identify the particular line of offending source code The parser has indicated the name of the file indicated the
272. is an internal compiler error Contact HI TECH Software technical support with details 382 incomplete record type length Dump Xstrip This message is produced by the DUMP or XSTRIP utilities and indicates that the object file is not a valid HI TECH object file or that it has been truncated Contact HI TECH Support with details 383 text record has length too small Linker This is an internal compiler error Contact HI TECH Software technical support with details 384 assertion failed file line expression Linker Parser This is an internal compiler error Contact HI TECH Software technical support with details 387 illegal or too many G options Linker There has been more than one linker g option or the g option did not have any arguments follow ing The arguments specify how the segment addresses are calculated 339 Error and Warning Messages 388 duplicate M option Linker The map file name has been specified to the linker for a second time This should not occur if you are using a compiler driver If invoking the linker manually ensure that only one instance of this option is present on the command line See Section 5 7 9 for information on the correct syntax for this option 389 illegal or too many O options Linker This linker o flag is illegal or another o option has been encountered A o option to the linker must be immediately followed by a filename with no intervening
273. is being used The processor type can also be indicated by use of the PROCESSOR directive in the assembler source file see Section 4 3 10 20 You can also add your own processors to the compiler via the compiler s chipinfo file Twidth This option allows specification of the assembly list file width in characters width should be a decimal number greater than 41 The default width is 80 characters V This option will include line number and filename information in the object file produced by the assembler Such information may be used by debuggers Note that the line numbers will correspond with assembler code lines in the assembler file This option should not be used when assembling an assembler file produced by the code generator from a C source file i e it should only be used with hand written assembler source files W warnlevel This option allow the warning threshold level to be set This will limit the number of warning messages produce when the assembler is executing The effect of this option is similar to the command line driver s WARN option see Section 2 6 57 See Section 2 5 for more information X The object file created by the assembler contains symbol information including local symbols i e symbols that are neither public or external The X assembler option will prevent the local symbols from being included in the object file thereby reducing the file size 112 Macro Assembler HI TECH C Assembly Language
274. is is an internal compiler error Contact HI TECH Software technical support with details 157 can t allocate bytes of memory Code Generator Assembler Optimiser This is an internal compiler error Contact HI TECH Software technical support with details 158 invalid disable in preprocessor macro Preprocessor This is an internal compiler error Contact HI TECH Software technical support with details 159 too many calls to unget Preprocessor This is an internal compiler error Contact HI TECH Software technical support with details 161 control line within preprocessor macro expansion Preprocessor A preprocessor control line one starting with a has been encountered while expanding a macro This should not happen 162 warning Preprocessor Driver This warning is either the result of user defined warning preprocessor directive or the driver en countered a problem reading the the map file If the latter then please HI TECH Software technical support with details 163 unexpected text in control line ignored Preprocessor This warning occurs when extra characters appear on the end of a control line e g The extra text will be ignored but a warning is issued It is preferable and in accordance with Standard C to enclose the text as a comment e g 297 Error and Warning Messages if defined END define NEXT endif END END would be better in a comment here 164 include f
275. is the comma unsigned chat b 373 implicit signed to unsigned conversion Parser An unsigned type was expected where a signed type was given and was implicitly cast to unsigned e g unsigned int foo 1 the above initialization is implicitly treated as unsigned int foo unsigned 1 374 missing basic type int assumed Parser The basic type of a cast to a qualified basic type was missing and assumed to be int e g int i signed 2 signed assumed to be signed int 375 unknown FNREC type Linker This is an internal compiler error Contact HI TECH Software technical support with details 338 Error and Warning Messages 376 bad non zero node in call graph Linker The linker has encountered a top level node in the call graph that is referenced from lower down in the call graph This probably means the program has indirect recursion which is not allowed when using a compiled stack 378 can t create file Hexmate This type of file could not be created Is the file or a file by this name already in use 379 bad record type Linker This is an internal compiler error Ensure the object file is a valid HI TECH object file Contact HI TECH Software technical support with details 380 unknown record type Linker This is an internal compiler error Contact HI TECH Software technical support with details 381 record too long Linker This
276. istributed into the address ranges wherever they will fit This means that if there are two or more psects in class CODE they may be intermixed in the address ranges Any psects allocated by a P option will have their load address range subtracted from any address ranges specified with the A option This allows a range to be specified with the A option without knowing in advance how much of the lower part of the range for example will be required for other psects 5 7 21 Qprocessor This option allows a processor type to be specified This is purely for information placed in the map file The argument to this option is a string describing the processor 5 7 22 S This option prevents symbol information relating from being included in the symbol file produced by the linker Segment information is still included 5 7 23 Sclass limit bound A class of psects may have an upper address limit associated with it The following example places a limit on the maximum address of the CODE class of psects to one less than 400h SCODE 400h Note that to set an upper limit to a psect this must be set in assembler code with a limit flag on a PSECT directive 146 Linker and Utilities Operation If the bound boundary argument is used the class of psects will start on a multiple of the bound address This example places the FARCODE class of psects at a multiple of 1000h but with an upper address limit of 6000h SFARCODE 6000h 1
277. ith the function and the linker will be able to check for correct argument passing For example if another c file contains the declaration extern char widget long then a different signature will be generated and the linker will report a signature mis match which will alert you to the possible existence of incompatible calling conventions C Language Features C Language Features Standard I O Functions and Serial I O Table 3 11 Supported standard I O functions Function name Purpose printf const char s Formatted printing to stdout sprintf char buf const char s Writes formatted text to buf 3 12 3 Linker Defined Symbols The link address of a psect can be obtained from the value of a global symbol with name __Lname where name is the name of the psect For example __Lbss is the low bound of the bss psect The highest address of a psect i e the link address plus the size is symbol __Hname If the psect has different load and link addresses the load start address is specified as __Bname 3 13 Standard I O Functions and Serial I O A number of the standard I O functions are provided specifically those functions intended to read and write formatted text on standard output and input A list of the available functions is in Table 3 11 More details of these functions can be found in Appendix A Before any characters can be written or read using these functions the putch and getch fun
278. itializes the random number generator accessed by rand with the given seed This provides a mechanism for varying the starting point of the pseudo random sequence yielded by rand On the Z80 a good place to get a truly random seed is from the refresh register Otherwise timing a response from the console will do or just using the system time Example include lt stdlib h gt include lt stdio h gt include lt time h gt void main void time_t toc int i time amp toc srand int toc for i 0 i 10 itt printf Sd t rand putchar n See Also rand 249 Library Functions STRCAT Synopsis include lt string h gt char strcat char sl const char s2 Description This function appends concatenates string s2 to the end of string s1 The result will be null termi nated The argument s1 must point to a character array big enough to hold the resultant string Example include lt string h gt include lt stdio h gt void main void char buffer 256 char sl s2 strcpy buffer Start of line sl buffer s2 end of line strcat s1 s2 printf Length d n strlen buffer printf string Ss n buffer See Also strepyO stremp strncat strlenQ Return Value The value of s1 is returned 250 Library Functions STRCHR STRICHR Synopsis include lt string h gt char strchr const char
279. ituation that is valid but which may lead to runtime failure of the code The code or situation that triggered the warning should be investigated however compilation of the current module will continue as will compilation of 37 Compiler Messages PICC32 Command line Driver any remaining modules Unless prevented by some driver option or another error message the project will be linked and the requested output file s will be generated Error Messages indicate source code that is illegal and that compilation of this code either cannot or will not take place Compilation will be attempted for the remaining source code in the current module but no additional modules will be compiled and the compilation process will then conclude The requested output files will not be produced Fatal Error Messages indicate a situation that cannot allow compilation to proceed and which re quired the the compilation process to stop immediately The requested output files will not be produced 2 5 4 Message Format By default messages are printed in the most useful human readable format as possible This format can vary from one compiler application to another since each application reports information about different file formats Some applications for example the parser are typically able to pinpoint the area of interest down to a position on a particular line of C source code whereas other applications such as the linker can at best only indica
280. ive HI TECH C will automatically save context when an interrupt occurs The compiler will determine only those registers and objects which need to be saved for the particular interrupt function defined The pragma regsused directive allows the programmer to indicate register usage for functions that will not be seen by the code generator for example if they were written in assembly code The general form of the pragma is pragma regsused routine_name register_list where routine_name is the assembly name of the function or routine whose register usage is being defined and register_list is a space separated list of registers names Those registers not listed are assumed to be unused by the function or routine The code generator may use any unspecified registers to hold values across a function call Hence if the routine does in fact use these registers unreliable program execution may eventuate The register names are not case sensitive and a warning will be produced if the register name is not recognised A blank list indicates that the specified function or routine uses no registers 3 11 4 4 The pragma switch Directive Normally the compiler decides the code generation method for switch statements which results in the smallest possible code size The pragma switch directive can be used to force the compiler to use one particular method The general form of the switch pragma is 101 Preprocessing C Language Features T
281. ject file Contact HI TECH Support with details 503 ident records do not match Linker The object files passed to the linker do not have matching ident records This means they are for different processor types 357 Error and Warning Messages 504 object code version is greater than Linker The object code version of an object module is higher than the highest version the linker is known to work with Check that you are using the correct linker Contact HI TECH Support if the object file if you have not patched the linker 505 no end record found inobject file Linker An object file did not contain an end record This probably means the file is corrupted or not an object file Contact HI TECH Support if the object file was generated by the compiler 506 object file record too long Linker This is an internal compiler error Contact HI TECH Software technical support with details 507 unexpected end of file in object file Linker This is an internal compiler error Contact HI TECH Software technical support with details 508 relocation offset out of range 0 1 Linker This is an internal compiler error Contact HI TECH Software technical support with details 509 illegal relocation size Linker There is an error in the object code format read by the linker This either means you are using a linker that is out of date or that there is an internal error in the assembler or linker C
282. kind of structure and the structures do not have a similar definition e g struct ONE unsigned a long b pike N ake one struct TWO unsigned a unsigned b J 1 two struct ONE oneptr oneptr amp two oops was ONE meant to be same struct as TWO 1267 fixup overflow referencing 0x into byte at 0x 0x Linker See the following error message 1268 for more information 411 Error and Warning Messages 1268 fixup overflow storing 0x in byte at 0x 0x Linker Fixup is the process conducted by the linker of replacing symbolic references to variables etc in an assembler instruction with an absolute value This takes place after positioning the psects program sections or blocks into the available memory on the target device Fixup overflow is when the value determined for a symbol is too large to fit within the allocated space within the assembler instruction For example if an assembler instruction has an 8 bit field to hold an address and the linker determines that the symbol that has been used to represent this address has the value 0x110 then clearly this value cannot be inserted into the instruction 1269 there day left until this licence will expire Driver This compiler has not been activated and is running as a demo The time indicated is how long the demo period will continue 1273 Omniscient Code Generation not available in Lite mode Drive
283. l header in the input Microchip COFF file indicates that the program or data memory spaces are zero bits wide 668 prefix list did not match any SDB types Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 669 prefix list matched more than one SDB type Cromwell This is an internal compiler error Contact HI TECH Software technical support with details 670 bad argument to T Clist The argument to the T option to specify tab size was not present or correctly formed The option expects a decimal interger argument 671 argument to T should be in range 1 to 64 Clist The argument to the T option to specify tab size was not in the expected range The option expects a decimal interger argument ranging from to 64 inclusive 673 missing filename after option Objtohex The indicated option requires a valid file name Ensure that the filename argument supplied to this option exists and is spelt correctly 674 too many references to Cref This is an internal compiler error Contact HI TECH Software technical support with details 679 unknown extraspecial Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 365 Error and Warning Messages 682 this architecture is not supported by the PICC Lite compiler Code Generator A target device other than baseline midrange or highend was specified This
284. l to ensure that preprocessor macros have expanded to what you think they should Use of this option can also create C source files which do not require any separate header files This is useful when sending files for technical support If you wish to see the preprocessed source for the printf family of functions do not use this option The source for this function is customised by the compiler but only after the code generator has scanned the project for printf usage Thus as the PRE option stops compilation after the preprocessor stage the code generator will not execute and no printf code will be processed If this option is omitted the preprocessed source for printf will be retained in the file doprnt pre If you wish to see the preprocessed source for the printf family of functions do not use this option The source for this function is customised by the compiler but only after the code generator has scanned the project for printf usage Thus as the PRE option stops compilation after the preprocessor stage the code generator will not execute and no printf code will be processed If this 57 PICC32 Driver Option Descriptions PICC32 Command line Driver option is omitted the preprocessed source for printf will be retained in the file doprnt pre 2 6 45 PROTO Generate Prototypes The PROTO option is used to generate pro files containing both ANSI and K amp R style function declarations for all functions within the specified s
285. lasses given for COFF write Cromwell Cromwell requires that the program memory psect classes be specified to produce a COFF file Ensure that you are using the N option as per Section 5 13 2 600 No chip arch given for COFF write Cromwell Cromwell requires that the chip architecture be specified to produce a COFF file Ensure that you are using the P option as per Section 5 13 1 601 Unknown chip arch for COFF write Cromwell The chip architecture specified for producing a COFF file isn t recognised by Cromwell Ensure that you are using the P option as per Section 5 13 1 and that the architecture specified matches one of those in Table 5 8 602 null file format name Cromwell The I or 0 option to Cromwell must specify a file format 603 ambiguous file format name Cromwell The input or output format specified to Cromwell is ambiguous These formats are specified with the ikey and okey options respectively 604 unknown file format name Cromwell The output format specified to CROMWELL is unknown e g cromwell m P16F877 main hex main sym ocot and output file type of cot did you mean cof 605 did not recognize format of input file Cromwell The input file to Cromwell is required to be COD Intel HEX Motorola HEX COFF OMF51 P amp E or HI TECH 361 Error and Warning Messages 606 inconsistent symbol tables Cromwell This is an internal compiler error Contact H
286. licit declaration causing a compiler error The solution is to ensure that all functions are defined or at least declared before use preferably with prototyped parameters If it is necessary to make a forward declaration of a function it should be preceded with the keywords extern or static as appropriate For example I may prevent an error arising from calls below void set long a int b void main void by here a prototype for set should have seen set 10L 6 362 redundant amp applied to array Parser The address operator has been applied to an array Since using the name of an array gives its address anyway this is unnecessary and has been ignored e g int array 5 int ip array is a constant not a variable the amp is redundant ip amp array 335 Error and Warning Messages 363 redundant amp or applied to function address Parser The address operator amp has been applied to a function Since using the name of a function gives its address anyway this is unnecessary and has been ignored e g extern void foo void void main void void bar void both assignments are equivalent bar fo0 bar foo the amp is redundant 364 attempt to modify object qualified Parser Objects declared const or code may not be assigned to or modified in any other way by your program The effect of attempting to modify such an object is compiler
287. line describing one checksum The syntax of a checksum line is 158 Linker and Utilities Objtohex Table 5 4 OBJTOHEX command line options Option Meaning 8 Produce a CP M 86 output file A Produce an ATDOS atx output file Bbase Produce a binary file with offset of base Default file name is l obj Cckfile Read a list of checksum specifications from ck file or standard input D Produce a COD file E Produce an MS DOS exe file Ffill Fill unused memory with words of value 111 default value is OFFh 1 Produce an ntel HEX file with linear addressed extended records L Pass relocation information into the output file used with exe files M Produce a Motorola HEX file S19 S28 or S37 format N Produce an output file for Minix Pstk Produce an output file for an Atari ST with optional stack size R Include relocation information in the output file Sfile Write a symbol file into file T Produce a Tektronix HEX file TE Produce an extended TekHEX file U Produce a COFF output file UB Produce a UBROF format file V Reverse the order of words and long words in the output file n m Format either Motorola or Intel HEX file where n is the maxi mum number of bytes per record and m specifies the record size rounding Non rounded records are zero padded to a multiple of m m itself must be a multiple of 2 159 Cref Linker
288. linked with the one PICC32 command For example to generate a cross reference listing which includes the source modules main c modulel c and nvram c compile and link using the command PICC32 CHIP 32MX360F512L CR main crf main c modulel c nvram c 50 PICC32 Command line Driver PICC32 Driver Option Descriptions Thus this option can not be used when using any compilation process that compiles each source file separately using the C or PASS1 options Such is the case for most IDEs including HI TIDE and makefiles 2 6 23 DEBUGGER t ype Select Debugger Type This option is intended for use for compatibility with debuggers PICC32 supports the Microchip ICD2 debugger and using this option will configure the compiler to conform to the requirements of the ICD2 reserving memory addresses etc For example PICC32 CHIP 32MX360F512L DEBUGGER icd2 main c Basic debugging with Microchip REALICE is also supported when debugger realice is used 2 6 24 ECHO Echo command line before processing Use of this option will result in the command line being echoed to the stderr stream before com pilation is commenced Each token of the command line will be printed on a separate line and will appear in the order in which they are placed on the command line 2 6 25 ERRFORMAT format Define Format for Compiler Messages If the ERRFORMAT option is not used the default behaviour of the compiler is to display any error
289. ll applications The compiler has attempted to load the messages for the selected language but the message descrip tion file MDF was corrupted and could not be read correctly 100 unterminated if n def block from line Preprocessor A if or similar block was not terminated with a matching endif e g if INPUT error flagged here void main void run no endif was found in this module 101 may not follow else Preprocessor A else or elif has been used in the same conditional block as a else These can only follow a if e g ifdef FOO result foo else result bar elif defined NEXT the else above terminated the if result next 0 endif 102 must be in an if Preprocessor The elif else or endif directive must be preceded by a matching if line If there is an apparently corresponding if line check for things like extra endif s or improperly terminated comments e g ifdef FOO result foo endif result bar elif defined NEXT the endif above terminated the if result next 0 endif 288 Error and Warning Messages 103 error Preprocessor This is a programmer generated error there is a directive causing a deliberate error This is normally used to check compile time defines etc Remove the directive to remove the error but first check as to why the directive is there 104 preprocessor assert fa
290. lso be qualified with static or made global An auto variable cannot be qualified as near 404 Error and Warning Messages 1183 invalid version number Activation During activation no matching version number was found on the HI TECH activation server database for the serial number specified 1184 activation limit reached Activation The number of activations of the serial number specified has exceeded the maximum number allowed for the license 1185 invalid serial number Activation During activation no matching serial number was found on the HI TECH activation server database 1186 licence has expired Driver The time limited license for this compiler has expired 1187 invalid activation request Driver The compiler has not been correctly activated 1188 network error Activation The compiler activation software was unable to connect to the HI TECH activation server via the network 1190 FAE license only not for use in commercial applications Driver Indicates that this compiler has been activated with an FAE licence This licence does not permit the product to be used for the development of commercial applications 1191 licensed for educational use only Driver Indicates that this compiler has been activated with an education licence The educational licence is only available to educational facilities and does not permit the product to be used for the development of commercial applications
291. lt For each interrupt function assigned a specific vector to service a corresponding entry is made in the table which jumps only to this function ram At each entry in the table the address of the current interrupt function for that vector is loaded from a separate table stored in RAM and indirectly invoked At startup the table in RAM is initialised by the runtime startup code with the interrupt vector functions specified in code with the operator The SETVECTOR macro can be used to assign an interrupt function to service a particular interrupt at runtime This macro is described in more detail in Appendix A Table 2 7 interrupts sub options affecting the type of interrupt vectors e sub options which affect the location of interrupt vector table see Table 2 8 e sub options which affect the number of vectors to service interrupts see Table 2 9 All sub options within each group are mutually exclusive If the driver detects confliciting or missing sub options within a particular group it will use the default sub option for that group This new driver option replaces the previous ivt option SUB OPTION MEANING boot default The vector table will be located in the device s boot flash memory and linked in KSEGO The precise location within this region isn t known until link time p m The vector table will be located in the device s program flash memory and linked in KSEGO The precise location within
292. ltime function 219 location counter 124 log function 221 LOG10 function 221 long data types 72 long integer suffix 69 longjmp function 222 ltoa function 224 MACRO directive 114 128 macros disabling in listing 134 expanding in listings 111 133 nul operator 129 predefined 97 repeat with argument 130 undefining 48 unnamed 130 main function 25 28 mantissa 72 map files 144 generating 47 processor selection 146 segments 149 431 INDEX INDEX symbol tables in 144 width of 147 maximum number of errors 51 MDE 36 mememp function 225 memory reserving 59 specifying 59 specifying ranges 141 unused 52 144 memory pages 124 memory summary 63 merging hex files 168 message language 37 message description files 36 messages disabling 55 warning 55 Microchip COF file 56 mixing C and assembly 88 mktime function 227 modf function 229 module 20 modules in library 155 list format 157 order in library 158 used in executable 144 MOVFF instruction 93 MPLAB 52 build options 46 multi character constants assembly 117 multiple hex files 142 near keyword 76 NOCOND assembler control 134 NOEXPAND assembler control 134 432 nojis pragma directive 100 NOLIST assembler control 134 non volatile memory 76 86 non volatile RAM 75 NOXREF assembler control 134 numbers C source 67 in linker options 140 nvbit psect 76 86 nvram 75 nvram psect 76 86
293. lues The minimum value min is preceded by a sign if present It sets a minimum value for the link or load address The address will be calculated as described below but if it is less than the minimum then it will be set equal to the minimum The link and load addresses are either numbers as described above or the names of other psects or classes or special tokens If the link address is a negative number the psect is linked in reverse order with the top of the psect appearing at the specified address minus one Psects following a negative address will be placed before the first psect in memory If a link address is omitted the psect s link address will be derived from the top of the previous psect e g Ptext 100h data bss In this example the text psect is linked at 100 hex its load address defaults to the same The data psect will be linked and loaded at an address which is 100 hex plus the length of the text psect rounded up as necessary if the data psect has a reloc value associated with it Similarly the bss psect will concatenate with the data psect Again Ptext 100h data bss will link in ascending order bss data then text with the top of text appearing at address Offh If the load address is omitted entirely it defaults to the same as the link address If the slash character is supplied but no address is supplied after it the load address will concatenate with the previous psect e g Ptext 0 data 0 bss
294. ly used by data bss or const type psects mipsl6e Indicates that the psect contains only executable MIPS 16e assembly mips32r2 Indicates that the psect contains only executable MIPS32r2 assembly The much abused ORG directive does not necessarily move the location counter to the absolute address you specify as the operand This directive is rarely needed in programs The argument to ORG must be either an absolute value or a value referencing the current psect In either case the current location counter is set to the value determined by the argument It is not possible to move the location counter backward For example ORG 100h will move the location counter to the beginning of the current psect plus 100h The actual location will not be known until link time In order to use the ORG directive to set the location counter to an absolute value the directive must be used from within an absolute overlaid psect For example PSECT absdata abs ovrld ORG 50h 4 3 10 5 EQU This pseudo op defines a symbol and equates its value to an expression For example thomas EQU 123h The identifier thomas will be given the value 123h EQU is legal only when the symbol has not previously been defined See also Section 4 3 10 6 125 HI TECH C Assembly Language Macro Assembler 4 3 10 6 SET This pseudo op is equivalent to EQU except that allows a symbol to be re defined For example thomas SET 0h 4 3 10 7 DB DB is
295. m bler to produce a raw cross reference file The utility CREF should be used to actually generate the formatted cross reference listing 135 HI TECH C Assembly Language Macro Assembler 136 Chapter 5 Linker and Utilities 5 1 Introduction HI TECH C incorporates a relocating assembler and linker to permit separate compilation of C source files This means that a program may be divided into several source files each of which may be kept to a manageable size for ease of editing and compilation then each source file may be compiled separately and finally all the object files linked together into a single executable program This chapter describes the theory behind and the usage of the linker Note however that in most instances it will not be necessary to use the linker directly as the compiler driver will automatically invoke the linker with all necessary arguments Using the linker directly is not simple and should be attempted only by those with a sound knowledge of the compiler and linking in general If it is absolutely necessary to use the linker directly the best way to start is to copy the linker arguments constructed by the compiler driver and modify them as appropriate This will ensure that the necessary startup module and arguments are present Note also that the linker supplied with HI TECH C is generic to a wide variety of compilers for several different processors Not all features described in this chapter are applica
296. m Consider removing it from the program 1091 main function not defined Code Generator The main function has not been defined Every C program must have a function called main 1094 bad derived type Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 1095 bad call to typeSub Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 1096 type should be unqualified Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 1097 unknown type string Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 1098 conflicting declarations for variable Parser Code Generator Differing type information has been detected in the declarations for a variable or between a declaratin and the definition of a variable e g extern long int test int test oops which is right int or long int 1104 unqualified error Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 1118 bad string in getexpr J Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 403 Error and Warning Messages 1119 bad string in getexpr LRN Code Generator This is an
297. milysupports passing parameters in any unused registers however this option will cause the program to follow the MIPS standard of using only the first 4 A registers for parameter passing To force only individual modules to use strict MIPS paramater passing see 3 5 2 62 PICC32 Command line Driver PICC32 Driver Option Descriptions Table 2 14 Memory Summary Suboptions Suboption Controls On implies psect Summary of psect usage A summary of psect names and the addresses they were linked at will be shown mem General summary of memory used A concise summary of memory used will be shown class Summary of class usage A summary of all classes in each memory space will be shown hex Summary of address used within the hex A summary of addresses and hex file files which make up the final out put file will be shown file Whether summary information is shown Summary information will be on the screen or shown and saved to a file shown on screen and saved to a file 2 6 54 SUMMARY type Select Memory Summary Output Type Use this option to select the type of memory summary that is displayed after compilation By default or if the mem suboption is selected a memory summary is shown This shows the total memory usage for all memory spaces A psect summary may be shown by enabling the psect suboption This shows individual psects after they have been grouped by the linker and the memory ranges t
298. mmon symbol psect conflict Linker A common symbol has been defined to be in more than one psect 482 symbol is defined more than once in Assembler This symbol has been defined in more than one place The assembler will issue this error if a symbol is defined more than once in the same module e g _next move r0 55 move rl r0 _next oops choose a different name The linker will issue this warning if the symbol C or assembler was defined multiple times in different modules The names of the modules are given in the error message Note that C identifiers often have an underscore prepended to their name after compilation 483 symbol can t be global Linker This is an internal compiler error Contact HI TECH Software technical support with details 484 psect can t be in classes and Linker A psect cannot be in more than one class This is either due to assembler modules with conflicting class options to the PSECT directive or use of the C option to the linker e g psect final class CODE finish elsewhere psect final class ENTRY 353 Error and Warning Messages 485 unknown with psect referenced by psect Linker The specified psect has been placed with a psect using the psect with flag The psect it has been placed with does not exist e g psect starttext class CODE with rext was that meant to be with text 486 psect selector
299. mory that may be used by read only ROM based objects and not necessarily those areas of memory which contain physical ROM The output that will be placed in the ranges specified by this option are typically executable code and any data variables that are qualified as const When producing code that may be downloaded into a system via a bootloader the destination memory may indeed be some sort of volatile RAM To only use on chip ROM memory this option is not required For example to specify an additional range of memory to that on chip use 59 PICC32 Driver Option Descriptions PICC32 Command line Driver ROM default 100 2ff for example To only use an external range and ignore any on chip memory use ROM 100 2ff This option may also be used to reserve memory ranges already defined as on chip memory in the chip configuration file To do this supply a range prefixed with a minus character for example ROM default 100 1ff will use all the defined on chip memory but not use the addresses in the range from 100h to 1ffh for allocation of ROM objects 2 6 48 The RUNTIME option is used to control what is included as part of the runtime environment The runtime environment encapsulates any code that is present at runtime which has not been defined by RUNTIME type Specify Runtime Environment the user instead supplied by the compiler typically as library code All runtime features except plib are enable
300. n define cc a b a b 138 strange character after Preprocessor An unprintable character has been seen after the token catenation operator that is neither a letter nor a digit Since the result of this operator must be a legal token the operands must be tokens containing only letters and digits e g the character will not lead to a valid token define cc a b a b 139 end of file in comment Preprocessor End of file was encountered inside a comment Check for a missing closing comment flag e g Here the comment begins I m not sure where I end though 140 can t open file Driver Preprocessor Code Generator Assembler The command file specified could not be opened for reading Confirm the spelling and path of the file specified on the command line e g picc communds should that be picc commands 295 Error and Warning Messages 141 can t open file Any An output file could not be created Confirm the spelling and path of the file specified on the com mand line 144 too many nested if blocks Preprocessor if ifdef etc blocks may only be nested to a maximum of 32 146 include filename too long Preprocessor A filename constructed while looking for an include file has exceeded the length of an internal buffer Since this buffer is 4096 bytes long this is unlikely to happen 147 too many include directories specified Prep
301. n 4 3 11 11 4 3 11 8 INCLUDE This control causes the file specified by pathname to be textually included at that point in the assembly file The INCLUDE control must be the last control keyword on the line for example OPT INCLUDE options h The driver does not pass any search paths to the assembler so if the include file is not located in the working directory the pathname must specify the exact location See also the driver option P in Section 2 6 11 which forces the C preprocessor to preprocess assembly file thus allowing use of preprocessor directives such as include see Section 3 11 2 133 HI TECH C Assembly Language Macro Assembler Table 4 11 LIST control options List Option Default Description c nnn 80 Set the page i e column width n nnn 59 Set the page length t 0N OFF OFF Truncate listing output lines The default wraps lines p lt processor gt n a Set the processor type r lt radix gt hex Set the default radix to hex dec or oct x 0N OFF OFF Turn macro expansion on or off 4 3 11 9 LIST If the listing was previously turned off using the NOLIST control the LIST control on its own will turn the listing on Alternatively the LIST control may includes options to control the assembly and the listing The options are listed in Table 4 11 See also the NOLIST control in Section 4 3 11 12 4 3 11 10 NOCOND Using this control will prevent conditional code f
302. n OPT CRE directive 6800 series assemblers or a XREF control line PIC assembler The general form of the CREF command is cref options files where opt ions is zero or more options as described below and files is one or more raw cross reference files CREF takes the options listed in Table 5 5 Each option is described in more detail in the following paragraphs 5 12 1 Fprefix It is often desired to exclude from the cross reference listing any symbols defined in a system header file e g lt stdio h gt The F option allows specification of a path name prefix that will be used to exclude any symbols defined in a file whose path name begins with that prefix For example F will exclude any symbols from all files with a path name starting with 160 Linker and Utilities Cref Table 5 5 CREF command line options Option Meaning Fprefix Exclude symbols from files with a pathname or filename starting with prefix Hheading Specify a heading for the listing file Llen Specify the page length for the listing file Ooutfile Specify the name of the listing file Pwidth Set the listing width Sstoplist Read file stoplist and ignore any symbols listed Xprefix Exclude and symbols starting with prefix 5 12 2 Hheading The H option takes a string as an argument which will be used as a header in the listing The default heading is the name of the first raw cross ref information file specif
303. n order are tested and invoked in the boot flash runtime startup code before device initialisation 1 user supplied powerup routine 2 non maskable interrupt and 3 soft reset 3 10 Mixing C and Assembly Code Assembly code can be mixed with C code using three different techniques The following section describes writing assembly code in separate assembly modules The subsequent section looks at two methods of having assembly code being placed in line with C code The following sections describe consideration of mixing assemby with C code and some of the special features the compiler uses to allow for assembly C code interation 88 C Language Features Mixing C and Assembly Code 3 10 1 External Assembly Language Functions Entire functions may be coded in assembly language as separate as source files assembled by the assembler ASPIC32 and combined into the binary image using the linker This technique allows arguments and return values to be passed between C and assembly code The following are guidelines that must be adhered to when writing a routine in assembly code that is callable from C code select or define a suitable psect for the executable assembly code select a name label for the routine so that its corresponding C identifier is valid ensure that the routine s label is globally accessible i e from other modules select an appropriate equivalent C prototype for the routine on which argument passing can be
304. n parameters or auto variables may be declared using the register qualifier e g register int gi this cannot be qualified register int process register int input this is okay return input gi 271 type can t be long Parser Only int and float can be qualified with long long char lc what 272 type can t be short Parser Only int can be modified with short e g short float sf what 273 type can t be both signed and unsigned Parser The type modifiers signed and unsigned cannot be used together in the same declaration as they have opposite meaning e g signed unsigned int confused which is it 318 Error and Warning Messages 274 type can t be unsigned Parser A floating point type cannot be made unsigned e g unsigned float uf what 275 illegal in non prototype argument list Parser The ellipsis symbol may only appear as the last item in a prototyped argument list It may not appear on its own nor may it appear after argument names that do not have types i e K amp R style non prototype function definitions For example K amp R style non prototyped function definition int kandr a b int a b 276 type specifier required for prototyped argument Parser A type specifier is required for a prototyped argument It is not acceptable to just have an identifier 277 can t mix prototyped and non prototyped argumen
305. n should be called check your source code Some assembler library routines are never called although they are actually execute In this case the routines are linked in a special sequence so that program execution falls through from one routine to the next 521 call depth exceeded by function Linker The call graph shows that functions are nested to a depth greater than specified 522 library is badly ordered Linker This library is badly ordered It will still link correctly but it will link faster if better ordered 523 argument to W option illegal and ignored Linker The argument to the linker option w is out of range This option controls two features For warning levels the range is 9 to 9 For the map file width the range is greater than or equal to 10 359 Error and Warning Messages 524 unable to open list file Linker The named list file could not be opened The linker would be trying to fixup the list file so that it will contain absolute addresses Ensure that an assembler list file was generated during the compilation stage Alternatively remove the assembler list file generation option from the link step 525 too many address memory spaces space ignored Linker The limit to the number of address spaces specified with the PSECT assembler directive is currently 16 526 psect not specified in P option first appears in Linker This psect was not specifi
306. n the end of a line If standard input is redirected from a file LIBR will take input from the file without prompting For example libr libr gt r file lib 1 0bj 2 0bj 3 0bj libr gt 4 0b3 5 0bj 6 0bj will perform much the same as if the object files had been typed on the command line The libr gt prompts were printed by LIBR itself the remainder of the text was typed as input libr lt lib cmd LIBR will read input from 1ib cmd and execute the command found therein This allows a virtually unlimited length command to be given to LIBR 5 10 5 Listing Format A request to LIBR to list module names will simply produce a list of names one per line on standard output The s keyletter will produce the same with a list of symbols after each module name Each symbol will be preceded by the letter D or U representing a definition or reference to the symbol respectively The P option may be used to determine the width of the paper for this operation For example 157 Objtohex Linker and Utilities LIBR P80 s file lib will list all modules in file 1lib with their global symbols with the output formatted for an 80 column printer or display 5 10 6 Ordering of Libraries The librarian creates libraries with the modules in the order in which they were given on the com mand line When updating a library the order of the modules is preserved Any new modules added to a library after it has been created will be appended to the en
307. nal memory ranges have been specified for the program space memory for the device specified 899 can t open option file for application Driver An option file specified by a getoption or setoption driver option could not be opened If you are using the setoption option ensure that the name of the file is spelt correctly and that it exists If you are using the getoption option ensure that this file can be created at the given location or that it is not in use by any other application 900 exec failed Driver The subcomponent listed failed to execute Does the file exist Try re installing the compiler 902 no chip name specified use CHIPINFO to see available chip names Driver The driver was invoked without selecting what chip to build for Running the driver with the CHIPINFO option will display a list of all chips that could be selected to build for 904 illegal format specified in option Driver The usage of this option was incorrect Confirm correct usage with HELP or refer to the part of the manual that discusses this option 389 Error and Warning Messages 905 illegal application specified in option Driver The application given to this option is not understood or does not belong to the compiler 907 unknown memory space tag in option specification Driver A parameter to this memory option was a string but did not match any valid tags Refer to the sec
308. nclosed in single quotes Multi character constants or strings are a sequence of characters not including carriage return or newline characters enclosed within matching quotes Either single quotes or double quotes maybe used but the opening and closing quotes must be the same 4 3 7 Identifiers Assembly identifiers are user defined symbols representing memory locations or numbers A sym bol may contain any number of characters drawn from the alphabetics numerics and the special characters dollar question mark and underscore _ The first character of an identifier may not be numeric The case of alphabetics is significant e g Fred is not the same symbol as fred Some examples of identifiers are shown here An _identifier an_identifier an_identifierl 4 3 7 1 Significance of Identifiers Users of other assemblers that attempt to implement forms of data typing for identifiers should note that this assembler attaches no significance to any symbol and places no restrictions or expectations on the usage of a symbol The names of psects program sections and ordinary symbols occupy separate overlapping name spaces but other than this the assembler does not care whether a symbol is used to represent 117 HI TECH C Assembly Language Macro Assembler bytes words or sports cars No special syntax is needed or provided to define the addresses of bits or any other data type nor will the assembler issue any warnings if
309. ned Preprocessor The symbol supplied as argument to undef was not already defined This warning may be disabled with some compilers This warning can be avoided with code like Hifdef SYM tundef SYM only undefine if defined endif 171 wrong number of preprocessor macro arguments for instead of Preprocessor A macro has been invoked with the wrong number of arguments e g define ADD a b a b ADD 1 2 3 oops only two arguments required 172 formal parameter expected after Preprocessor The stringization operator not to be confused with the leading used for preprocessor control lines must be followed by a formal macro parameter e g define str x ty oops did you mean x instead of y If you need to stringize a token you will need to define a special macro to do it e g define __mkstr__ x x then use __mkstr__ token wherever you need to convert a token into a string 173 undefined symbol in if 0 used Preprocessor A symbol on a if expression was not a defined preprocessor macro For the purposes of this expression its value has been taken as zero This warning may be disabled with some compilers Example if FOO BAR e g FOO was never defined define GOOD Hendif 299 Error and Warning Messages 174 multi byte constant isn t portable Preprocessor Multi byte constants are not portable and in fact will be rejected by later p
310. ned to a variable This may mean you have inadvertently used an assignment instead of a compare e g int a b this can never be false always perform the true statement if a 4 b 6 will assign the value 4 to a then as the value of the assignment is always true the comparison can be omitted and the assignment to b always made Did you mean this can never be false always perform the true statement if a 4 b 6 which checks to see if a is equal to 4 759 expression generates no code Code Generator This expression generates no output code Check for things like leaving off the parentheses in a function call e g int fred fred this is valid but has no effect at all Some devices require that special function register need to be read to clear hardware flags To accommodate this in some instances the code generator does produce code for a statement which only consists of a variable ID This may happen for variables which are qualified as volatile Typically the output code will read the variable but not do anything with the value read 760 portion of expression has no effect Code Generator Part of this expression has no side effects and no effect on the value of the expression e g int dy bc a b c b has no effect was that meant to be a comma 376 Error and Warning Messages 761 sizeof yields 0 Code Generator The code generator has taken
311. nerate a map file Search for the string UNUSED ADDRESS RANGES Under this heading look for the name of the segment specified in the error message If the name is not present then all the memory available for this psect has been allocated If it is present there will be one address range specified under this segment for each free block of memory Determine the size of each block and compare this with the number of words specified in the error message Psects containing code can be reduced by using all the compiler s optimizations or restructuring the program If a code psect must be split into two or more small psects this requires splitting a function into two or more smaller functions which may call each other These functions may need to be placed in new modules Psects containing data may be reduced when invoking the compiler optimizations but the effect is less dramatic The program may need to be rewritten so that it needs less variables Section has information on interpreting the map file s call graph if the compiler you are using uses a compiled stack If the string Call graph is not present in the map file then the compiled code uses a hardware stack If a data psect needs to be split into smaller psects the definitions for variables will need to be moved to new modules or more evenly spread in the existing modules Memory allocation for auto variables is entirely handled by the compiler Other than reducing the number of these
312. nformation regarding this option as well as an overview of the messaging system and other related driver options 43 PICC32 Driver Option Descriptions PICC32 Command line Driver 2 6 4 Gfile Generate Source level Symbol File The G option generates a source level symbol file i e a file which allows tools to determine which line of source code is associated with machine code instructions and determine which source level variable names correspond with areas of memory etc for use with supported debuggers and simu lators such as HI TIDE and MPLAB If no filename is given the symbol file will have the same base name as the project name see Section 2 1 and an extension of sym For example the option Gtest sym generates a symbol file called test sym Symbol files generated using the G option include source level information for use with source level debuggers Note that all source files for which source level debugging is required should be compiled with the G option The option is also required at the link stage if this is performed separately For example PICC32 CHIP 32MX360F512L G PASS1 test c modulesl c PICC32 CHIP 32MX360F512L Gtest sym test pl modulel pl The IDE option see Section 2 6 30 will typically enable the G option 2 6 5 Ipath Include Search Path Use I to specify an additional directory to use when searching for header files which have been included using the include directive The I
313. nk and location of a psect as within a class when that psect was also defined using a with psect flag 356 Error and Warning Messages 497 psect exceeds max size h gt h Linker The psect has more bytes in it than the maximum allowed as specified using the size psect flag 498 psect exceeds address limit h gt h Linker The maximum address of the psect exceeds the limit placed on it using the limit psect flag Either the psect needs to be linked at a different location or there is too much code data in the psect 499 undefined symbol Assembler Linker The symbol following is undefined at link time This could be due to spelling error or failure to link an appropriate module 500 undefined symbols Linker A list of symbols follows that were undefined at link time These errors could be due to spelling error or failure to link an appropriate module 501 program entry point is defined more than once Linker There is more than one entry point defined in the object files given the linker End entry point is specified after the END directive The runtime startup code defines the entry point e g powerup goto start END powerup end of file and define entry point other files that use END should not define another entry point 502 incomplete record body length Linker An object file contained a record with an illegal size This probably means the file is truncated or not an ob
314. nt Example scanf Sd s amp a amp C with input 12s will assign 12 to a and s to s See Also fscanf sscanfQ printf va_argO Return Value The scanf function returns the number of successful conversions EOF is returned if end of file was seen before any conversions were performed 243 Library Functions SETJMP Synopsis include lt setjmp h gt int setjmp jmp_buf buf Description The setjmp function is used with longjmp for non local goto s See longjmpQ for further infor mation Example include lt stdio h gt include lt setjmp h gt include lt stdlib h gt jmp_buf jb void inner void longjmp jb 5 void main void int iy if i setjmp jb printf setjmp returned d n i exit 0 printf setjmp returned 0 good n printf calling inner n 244 Library Functions inner printf inner returned bad n See Also longjmpQ Return Value The setjmp function returns zero after the real call and non zero if it apparently returns after a call to longjmpQ 245 Library Functions SETVECTOR Synopsis void interrupt ISR void SETVECTOR n ISR Description This routine is used to assign an interrupt function to service a particular interrupt at runtime The first argument should be the vector number between 0 and 63 The second argument should be the function which you want the interrupt v
315. nterrupt function may be assigned this duty and only at compile time If no interrupt function is assigned this duty the compiler will generate a default handler which consists solely of an infinite loop Bootstrap Exceptions An interrupt function may be assigned the duty of servicing bootstrap excep tions by addressing it with the macro BOOTSTRAP_EXCEPTION defined in lt pic32 h gt Only one interrupt function may be assigned this duty and only at compile time If no interrupt func tion is assigned this duty the compiler will generate a default handler which consists solely of an infinite loop Soft resets An interrupt function may be assigned the duty of servicing a soft reset by addressing it with the macro SOFT_RESET in defined lt pic32 h gt Only one interrupt function may be assigned this duty and only at compile time If no interrupt function is assigned this duty the compiler will not add a test for a soft reset in the runtime startup code or generate a default handler General interrupt function An interrupt function may be assigned the duty of servicing any un specified interrupts by addressing it with the macro GENERAL_INTERRUPT defined in lt pic32 h gt Only one interrupt function may be assigned this duty and only at compile time If no inter rupt function is assigned this duty the compiler will not generate a default general interrupt function 3 9 3 Runtime Startup Callback Sequence The following conditions and callbacks i
316. nts are as follows num Specifies a specific size for the stack heap in num number of bytes Note that the stack heap is required to be word i e 4 bytes aligned and in units of words Therefore any size specified will be rounded down to the nearest whole word quantity min num Specifies the minimum number of num bytes the stack heap must be max num Specifies the maximum number of num bytes the size of the stack heap is restricted to If any kind of size restriction is placed on either or both of these regions then each is allocated its own psect Each psect will be as large as permitted by those restrictions The stack psect will be linked as high as possible and the heap psect will be linked as low as possible The growth of the stack and heap remains unchanged 31 Runtime Files PICC32 Command line Driver CONFIG WORD SETTINGS OxBFCO2FFC Code protection disabled Boot flash write protect disabled Program write protection disabled ICE ICD comm communication uses PGC2 PGD2 pins Background ICE debugger enabled OxBFCO2FF8 WDT Disabled with 1 1 postscale Clock switching and fail safe clock monitor enabled PBCLK is SYSCLK divided by 1 CLKO disabled Primary oscillator in HS mode Internal external switch over mode enabled Secondary oscillator enabled Fast RC oscillator with divide by N with PPL module OxBFCO2FF4 PLL output divided by 1 for 80MHz devices or PLL output divided by 2 for 40MHz devices 20x initial PLL mult
317. number of calls to strtok breaks the string s1 which consists of a sequence of zero or more text tokens separated by one or more characters from the separator string s2 into its separate tokens The first call must have the string s1 This call returns a pointer to the first character of the first token or NULL if no tokens were found The inter token separator character is overwritten by a null character which terminates the current token For subsequent calls to strtok s1 should be set to a null pointer These calls start searching from the end of the last token found and again return a pointer to the first character of the next token or NULL if no further tokens were found Example tinclude lt stdio h gt tinclude lt string h gt void main void char ptr char buf This is a string of words char sep_tok ptr strtok buf sep_tok while ptr NULL printf Ss n ptr ptr strtok NULL sep_tok 272 Library Functions Return Value Returns a pointer to the first character of a token or a null pointer if no token was found Note The separator string s2 may be different from call to call 273 Library Functions TAN Synopsis include lt math h gt double tan double f Description The tan function calculates the tangent of f Example include lt math h gt include lt stdio h gt define C 3 141592 180 0 void main void double i for
318. numerated value Code Generator An enumerated value larger than the maximum value supported by this compiler was detected and has been truncated e g enum ZERO ONE BIG 0x99999999 test_case 701 unreasonable matching depth Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 702 regused bad arg to G Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 703 bad GN Code Generator This is an internal compiler error Contact HI TECH Software technical support with details See Section 5 7 2 for more information 704 bad RET_MASK Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 705 bad which after I Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 706 bad which in expand Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 707 bad SX Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 367 Error and Warning Messages 708 bad mod for how Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 709 metaregister can t be used directly Code Generator This is an int
319. o printed by the compiler when the message is issued The messages shown here are sorted by their number Un numbered messages appear toward the end and are sorted alphabetically The name of the application s that could have produced the messages are listed in brackets opposite the error message In some cases examples of code or options that could trigger the error are given The use of in the error message is used to represent a string that the compiler will substitute that is specific to that particular error Note that one problem in your C or assembler source code may trigger more than one error message 1 too many errors all applications The executing compiler application has encountered too many errors and will exit immediately Other uncompiled source files will be processed but the compiler applications that would normally be executed in due course will not be run The number of errors that can be accepted can be con trolled using the ERRORS option See Section 2 6 26 2 error warning generated but no description available all applications The executing compiler application has emitted a message advisory warning error but there is no description available in the message description file MDF to print This may be because the MDF is out of date or the message issue has not been tranlated into the selected language 287 Error and Warning Messages 3 malformed error information on line in file a
320. o we use an ordinary looking psect that you would see in assembly code produced by the compiler The psect s name is text32 It will be linked somewhere in the range of addresses defined by the CODE class PSECT text32 class CODE Now we would like to call this routine as add in the C code Thus in assembly code we must choose the name _add as this then maps to the C identifier add If the name add was chosen for the assembly routine label then it could never be called from C code The name of the assembly routine is the label that we will associate with the assembly code _add We need to be able to call this from other modules so make this label globally accessi ble GLOBAL _add By compiling a dummy C function with a similar prototype to the prototype we require for our function add we can determine the signature value To see the value generate an assembly list file and compile with the assembler optimizer turned off Look for a directive similar to that below which can then be copied into the assembly source for our add routine SIGNAT _add 8298 When writing the function you can find that the parameters will be loaded into the function s parameter area by the calling function and the result should be placed in the same location to be returned To call an assembly routine from C code a declaration for the routine must be provided This ensures that the compiler knows how to encode the function call in terms of parame
321. ode generator produces only one as file from all c pl and 1pp input files which it is passed Dotted lines indicate a process that may require an option to create or preserve the indicated file 22 PICC32 Command line Driver The Compilation Sequence Figure 2 2 Flow diagram of the final compilation sequence N hex map SE HLINK LL TNODEL obj y OBJTOHEX AA HEXMATE gt Pe A CROMWELL The link and post link steps are graphically illustrated in Figure 2 2 This diagram shows hex files as additional input file type not considered in the initial compi lation sequence These files can be merged into the hex file generated from the other input files in the project by an application called HEXMATE See Section 5 14 for more information on this utility The output of the linker is a single absolute object file called 1 0b3 that can be preserved by using the NODEL driver option Without this option this temporary file is used to generate an output file e g a HEX file and files used for debugging by development tools e g COFF files before it is deleted The file 1 0b3 can be used as the input to OBJTOHEX if running this application manually but it cannot be passed to the driver as an input file as it absolute and cannot be further processed 2 2 1 Single step Compilation The command line driver PICC32 can compile any mix of input files in a single step All s
322. ode generator has been passed a pragma psect directive that has a badly formed string e g pragma psect text redirect text psect into what Maybe you meant something like pragma psect text special_text 734 too many psect pragmas Code Generator Too many pragma psect directives have been used 735 bad string in pragma stack_size Code Generator The argument to the stack_size pragma is malformed This pragma must be followed by a number representing the maximum allowed stack size 370 Error and Warning Messages 737 unknown argument to pragma switch Code Generator The pragma switch directive has been used with an invalid switch code generation method Pos sible arguments are auto simple and direct 739 error closing output file Code Generator Optimiser The compiler detected an error when closing a file Contact HI TECH Support with details 740 zero dimension array is illegal Code Generator The code generator has been passed a declaration that results in an array having a zero dimension 741 bitfield too large bits Code Generator The maximum number of bits in a bit field is the same as the number of bits in an int e g assuming an int is 16 bits wide struct unsigned flag 1 unsigned value 12 unsigned cont 6 oops that s a total of 19 bits object 742 function argument evaluation overlapped Linker A function call involves
323. oes actually mark the end of the file 806 attempted to get an undefined object Assembler This is an internal compiler error Contact HI TECH Software technical support with details 807 attempted to set an undefined object Assembler This is an internal compiler error Contact HI TECH Software technical support with details 808 bad size in add_reloc Assembler This is an internal compiler error Contact HI TECH Software technical support with details 809 unknown addressing mode Assembler Optimiser An unknown addressing mode was used in the assembly file 811 cnt too large in displayO Assembler This is an internal compiler error Contact HI TECH Software technical support with details 815 syntax error in chipinfo file at line Assembler The chipinfo file contains non standard syntax at the specified line 816 duplicate ARCH specification in chipinfo file at line Assembler Driver The chipinfo file has a processor section with multiple ARCH values Only one ARCH value is allowed If you have not manually edited the chip info file contact HI TECH Support with details 817 unknown architecture in chipinfo file at line Assembler Driver An chip architecture family that is unknown was encountered when reading the chip INI file 382 Error and Warning Messages 819 duplicate ZEROREG for in chipinfo file at line Assembler The chipinfo file has a
324. ompiler s chip configuration file You may need to contact HI TECH Software to see if support for this device is available or upgrade the version of your compiler 923 unknown suboption Driver This option can take suboptions but this suboption is not understood This may just be a simple spelling error If not HELP to look up what suboptions are permitted here 924 missing argument to option Driver This option expects more data but none was given Check the usage of this option 925 extraneous argument to option Driver This option does not accept additional data yet additional data was given Check the usage of this option 926 duplicate option Driver This option can only appear once but appeared more than once 928 bad option value Driver Assembler The indicated option was expecting a valid hexadecimal integer argument 929 bad option ranges Driver This option was expecting a parameter in a range format start_of_range end_of_range but the parameter did not conform to this syntax 930 bad option specification Driver The parameters to this option were not specified correctly Run the driver with HELP or refer to the driver s chapter in this manual to verify the correct usage of this option 931 command file not specified Driver Command file to this application expected to be found after or lt on the command line was not found 391 Er
325. on they themselves must be globally accessible to allow each calling function to load their contents The C auto and parameter variable identifiers are local symbols that only have scope in the function in which they are defined Each symbol is shown with the psect in which they are placed and the address which the symbol has been assigned There is no information encoded into a symbol to indicate whether it represents code or variables nor in which memory space it resides 154 Linker and Utilities Librarian If the psect of a symbol is shown as abs this implies that the symbol is not directly associated with a psect as is the case with absolute C variables Linker defined symbols showing this as the psect name may be symbols that have never been used throughout the program or relate to symbols that are not directly associated with a psect Note that a symbol table is also shown in each assembler list file See Section 2 6 17 for in formation on generating these files These differ to that shown in the map file in that they list all symbols whether they be of global or local scope and they only list the symbols used in the module s associated with that list file 5 10 Librarian The librarian program LIBR has the function of combining several object files into a single file known as a library The purposes of combining several such object modules are several e fewer files to link e faster access e uses less disk space In
326. on 2 6 35 This option takes a comma separated list of message numbers Any warnings which are listed are disabled and will never be issued regardless of any warning level threshold in place This option cannot be used to disable error messages Some warning messages can also be disabled by using the warning disable pragma This pragma will only affect warnings that are produced by either parser or the code generator i e errors directly associated with C code See Section 3 11 4 5 for more information on this pragma Error messages can also be disabled however a slighty more verbose form of the command is required to confirm the action required To specify an error message number in the MSGDISABLE command the number must be followed by off to ensure that it is actually disabled For example MSGDISABLE 195 o0ff will disable error number 195 Disabling error or warning messages in no way fixes any potential problems reported by the message Always use caution when exercising this option 2 5 5 2 Changing Message Types It is also possible to change the type of some messages This is only possible by the use of the warning pragma and only affects messages generated by the parser or code generator See Section 3 11 4 5 for more information on this pragma 2 6 PICC32 Driver Option Descriptions Most aspects of the compilation can be controlled using the command line driver PICC32 The driver will configure and execute all required applica
327. on inside function Parser A function contains an extern declaration This is legal but is invariably not desirable as it restricts the scope of the function declaration to the function body This means that if the compiler encounters another declaration use or definition of the extern object later in the same file it will no longer have the earlier declaration and thus will be unable to check that the declarations are consistent This can lead to strange behaviour of your program or signature errors at link time It will also hide any previous declarations of the same thing again subverting the compiler s type checking As a general rule always declare extern variables and functions outside any other functions For example int process int a this would be better outside the function extern int away return away a 348 auto variable should not be qualified Parser An auto variable should not have qualifiers such as near or far associated with it Its storage class is implicitly defined by the stack organization An auto variable may be qualified with static but it is then no longer auto 349 non prototyped function declaration for Parser A function has been declared using old style K amp R arguments It is preferable to use prototype declarations for all functions e g int process input int input warning flagged here This would be better written 331 Error and Warning Messag
328. on when using the d key e g libr d c ht pic lib pic704 c lib does not indicate which modules to delete try something like libr d c ht pic lib pic704 c lib wdiv obj 0 incomplete ident record Libr The IDENT record in the object file was incomplete Contact HI TECH Support with details 0 incomplete symbol record Libr The SYM record in the object file was incomplete Contact HI TECH Support with details 0 library file names should have lib extension Libr Use the 1ib extension when specifying a library filename 0 module defines no symbols Libr No symbols were found in the module s object file This may be what was intended or it may mean that part of the code was inadvertently removed or commented 0 replace what Libr The librarian requires one or more modules to be listed for replacement when using the r key e g libr r led lib This command needs the name of a module obj file after the library name 413 Error and Warning Messages 414 Appendix C Chip Information The following table lists all devices currently supported by HI TECH C PRO for the PIC32 MCU Family Table C 1 Devices supported by HI TECH C PRO for the PIC32 MCU Family DEVICE FLASH RAM BOOT FREQ 32MX300F032H 8000 2000 2FFO 28 32MX310F032H 8000 2000 2FFO 28 32MX320F032H 8000 2000 2FFO 28 32MX320F064H 10000 4000 2FFO 50 32MX320F128H 20000 4000 2FFO 50 32MX320F128L 20000 4000 2FFO 50 32MX340F128H
329. ontact HI TECH Support with details if the object file was created by the compiler 510 complex relocation not supported for R or L options Linker The linker was given a R or L option with file that contain complex relocation 511 bad complex range check Linker This is an internal compiler error Contact HI TECH Software technical support with details 512 unknown complex operator 0x Linker This is an internal compiler error Contact HI TECH Software technical support with details 358 Error and Warning Messages 513 bad complex relocation Linker The linker has been asked to perform complex relocation that is not syntactically correct Probably means an object file is corrupted 514 illegal relocation type Linker An object file contained a relocation record with an illegal relocation type This probably means the file is corrupted or not an object file Contact HI TECH Support with details if the object file was created by the compiler 515 unknown symbol type Linker This is an internal compiler error Contact HI TECH Software technical support with details 516 text record has bad length 1 lt 0 Linker This is an internal compiler error Contact HI TECH Software technical support with details 520 function is never called Linker This function is never called This may not represent a problem but space could be saved by remov ing it If you believe this functio
330. or all other values 2 6 10 Ofile Specify Output File This option allows the basename of the output file s to be specified If no O option is given the output file s will be named after the first source or object file on the command line The files controlled are any produced by the linker or applications run subsequent to that e g CROMWELL So for instance the HEX file MAP file and SYM file are all controlled by the 0 option The 0 option can also change the directory in which the output file is located by including the required path before the filename e g Oc project output first This will then also specify the output directory for any files produced by the linker or subsequently run applications Any relative paths specified are with respect to the current working directory Any extension supplied with the filename will be ignored The name and path specified by the 0 option will apply to all output files 47 PICC32 Driver Option Descriptions PICC32 Command line Driver The options that specify MAP file creation M see 2 6 8 and SYM file creation G see 2 6 4 override any name or path information provided by O relevant to the MAP and SYM file To change the directory in which all output and intermediate files are written use the OUTDIR option see Section 2 6 41 Note that if O specifies a path which is inconsistent with the path specified in the OUTDIR option this will result in an error 2 6 11 P Pre
331. or messages to the specified file instead of the screen which is the default standard error destination 5 7 8 F Normally the linker will produce an object file that contains both program code and data bytes and symbol information Sometimes it is desired to produce a symbol only object file that can be used again in a subsequent linker run to supply symbol values The F option will suppress data and code bytes from the output file leaving only the symbol records This option can be used when producing more than one hex file for situations where the program is contained in different memory devices located at different addresses The files for one device are compiled using this linker option to produce a symbol only object file this is then linked with the files for the other device The process can then be repeated for the other files and device 5 7 9 Gspec When linking programs using segmented or bank switched psects there are two ways the linker can assign segment addresses or selectors to each segment A segment is defined as a contiguous group of psects where each psect in sequence has both its link and load address concatenated with the previous psect in the group The segment address or selector for the segment is the value derived when a segment type relocation is processed by the linker By default the segment selector will be generated by dividing the base load address of the seg ment by the relocation quantum of the segment
332. or will result This is not true if a symbol is defined twice in source files For example if you wished to make changes to the library function max which resides in the file max c in the SOURCES directory you could make a copy of this source file make the appropriate changes and then compile and use it as follows PICC32 chip 32MX360F512L main c init c max c The code for max in max c will be linked into the program rather than the max function con tained in the standard libraries Note that if you replace an assembler module you may need the P option to preprocess assembler files as the library assembler files often contain C preprocessor directives 3 12 2 Signature Checking The compiler automatically produces signatures for all functions A signature is a 16 bit value computed from a combination of the function s return data type the number of its parameters and other information affecting the calling sequence for the function This signature is output in the object code of any function referencing or defining the function 105 Linking Programs At link time the linker will report any mismatch of signatures HI TECH C PRO for the PIC32 MCU Family is only likely to issue a mismatch error from the linker when the routine is either a precompiled object file or an assembly routine Other function mismatches are reported by the code generator 106 TUTORIAL It is sometimes necessary to write assembly language r
333. ormats E Strip file extensions B Specify big endian byte ordering M Strip underscore character V Verbose mode 5 13 1 Pnamel architecture The P options takes a string which is the name of the processor used CROMWELL may use this in the generation of the output format selected Note that to produce output in COFF format an additional argument to this option which also specifies the processor architecture is required Hence for this format the usage of this option must take the form Pname architecture Table 5 8 enumerates the architectures supported for producing COFF files 5 13 2 N To produce some output file formats e g COFF Cromwell requires that the names of the program memory space psect classes be provided The names of the classes are given as a comma separated list For example in the DSPIC C compiler these classes are typically CODE and NEARCODE i e NCODE NEARCODE 5 133 D The D option is used to display to the screen details about the named input file in a readable format The input file can be one of the file types as shown in Table 5 6 163 Cromwell Linker and Utilities Table 5 8 P option architecture arguments for COFF file output Architecture Description 68K Motorola 68000 series chips H8 300 Hitachi 8 bit H8 300 chips H8 300H Hitachi 16 bit H8 300H chips SH Hitachi 32 bit SuperH RISC chips PIC12 Microchip base line PIC chips
334. ot be resolved This can happen if the checksum result was to be stored within the address range of the checksum calculation 948 checksum result width must be between 1 and 4 bytes Hexmate The requested checksum byte size is illegal Checksum results must be within to 4 bytes wide Check the parameters to the CKSUM option 949 start of checksum range must be less than end of range Hexmate The CKSUM option has been given a range where the start is greater than the end The parameters may be incomplete or entered in the wrong order 392 Error and Warning Messages 951 start of fill range must be less than end of range Hexmate The FILL option has been given a range where the start is greater than the end The parameters may be incomplete or entered in the wrong order 953 unknown HELP sub option Hexmate Invalid sub option passed to HELP Check the spelling of the sub option or use HELP with no sub option to list all options 956 SERIAL value must be between 1 and bytes long Hexmate The serial number being stored was out of range Ensure that the serial number can be stored in the number of bytes permissible by this option 958 too many input files specified file maximum Hexmate Too many file arguments have been used Try merging these files in several stages rather than in one command 960 unexpected record type on line of Hexmate Intel hex file contained an invalid record type Consul
335. ource files will be re compiled regardless of whether they have been changes since that last time a compi lation was performed Unless otherwise specified a default output file and debug file are produced All intermedi ate files p1 and ob3 remain after compilation has completed but all other transitional files are deleted unless you use the NODEL option which preserves all generated files Note some generated files may be in a temporary directory not associated with your project and use a pseudo randomly 23 The Compilation Sequence PICC32 Command line Driver generated filename TUTORIAL SINGLE STEP COMPILATION The files main c io c mdef as sprt obj a_sb lib and c_sb lpp are to be compiled To perform this in a single step the following com mand line can be used as a starting point for the project development PICC32 chip 32MX360F512L main c io c mdef as sprt obj a_sb lib c_sb lpp This will run the C pre processor then the parser with main c as input and then again for io c producing two p code files These two files in addition to the library file c_sb lpp are passed to the code generator producing a single temporary assembler file output The assembler is then executed and is passed the output of the code generator It is run again with mdef as producing two relocatable object files The linker is then executed passing in the assembler output files in addition to sprt obj and the library file a_sb 1ib The o
336. ource files Each pro file produced will have the same base name as the corresponding source file Prototype files contain both ANSI C style prototypes and old style C function declarations within conditional compilation blocks The extern declarations from each pro file should be edited into a global header file which is included in all the source files comprising a project The pro files may also contain static decla rations for functions which are local to a source file These static declarations should be edited into the start of the source file To demonstrate the operation of the PROTO option enter the following source code as file test c tinclude lt stdio h gt add argl arg2 int argl int arg2 return argl arg2 void printlist int list int count while count printf sd list putchar An If compiled with the command PICC32 CHIP 32MX360F512L PROTO test c PICC32 will produce test pro containing the following declarations which may then be edited as necessary Prototypes from test c extern functions include these in a header file Hif PROTOTYPES extern int add int int 58 PICC32 Command line Driver PICC32 Driver Option Descriptions extern void printlist int int telse PROTOTYPES extern int add extern void printlist tendif PROTOTYPES 2 6 46 RAM lo hi lt lo hi gt Specify Additional RAM Ranges This option is
337. ous combinations of LI SLL ADDIU and NEG instructions For immediate operands which cannot be determined until link time the appropriate value is stored in a small in situ table and loaded into rx with a LW instruction relative to the pc LWPC rx offset A synonym of LW rx offset pc 113 HI TECH C Assembly Language Macro Assembler 4 3 2 Instruction Operand Variants Many of the 2 or 3 operand assembly machine and in built instructions have variants with less operands supported by the assembler These variants have been enumerated in Tables 4 2 and 4 3 for both MIPS32r2 and MIPS16e assembly respectively 4 3 3 Statement Formats Legal statement formats are shown in Table 4 4 The label field is optional and if present should contain one identifier A label may appear on a line of its own or precede a mnemonic as shown in the second format The third format is only legal with certain assembler directives such as MACRO SET and EQU The name field is mandatory and should also contain one identifier If the assembly file is first processed by the C preprocessor see Section 2 6 11 then it may also contain lines that form valid preprocessor directives See Section 3 11 2 for more information on the format for these directives There is no limitation on what column or part of the line in which any part of the statement should appear 4 3 4 Characters The character set used is standard 7 bit ASCII Alphabetic case is significan
338. outines which are called from C using an extern declaration Such assembly language functions should include a signa ture which is compatible with the C prototype used to call them The simplest method of determining the correct signature for a function is to write a dummy C function with the same prototype and compile it to assembly language using the PICC32 S option For example suppose you have an assembly language routine called _widget which takes two int arguments and returns a char value The prototype used to call this function from C would be extern char widget int int Where a call to_widget is made in the C code the signature for a function with two int arguments and a char return value would be generated In order to match the correct signature the source code for widget needs to contain an assembler SIGNAT pseudo op which defines the same signature value To determine the correct value you would write the following code char widget int argl int arg2 and compile it to assembly code using PICC32 S x c The resultant assembly code includes the following line SIGNAT _widget 8249 The SIGNAT pseudo op tells the assembler to include a record in the obj file which associates the value 8249 with symbol _widget The value 8249 is the correct signature for a function with two int arguments and a char return value If this line is copied into the as file where _widget is defined it will associate the correct signature w
339. output routines The range of these functions are described in Appendix A These libraries also contain assembler level routines that are implicitly called by the output code of the code generator These are routines that perform tasks such as floating point operations and that do not directly correspond to a C function call in the source code The general form of the standard library names is pic32 c 1pp The meaning of each field is described by e Processor Type is always pic e Processor Range is 32 for the PIC32 family e Library Type is always c e The extension is lpp for p code libraries 2 3 1 2 Peripheral Libraries HI TECH C PRO for the PIC32 MCU Family has support for all of Microchip s PIC32 peripheral libraries The source for these routines can be viewed in the sources and include directories of the compiler For more information concerning peripheral libraries please visit Microchip s website Note that to use peripheral libraries the RUNTIME p1ib option will need to be used See Section 2 6 48 2 3 2 Runtime Startup Module A C program requires certain objects to be initialised and the processor to be in a particular state before it can begin execution of its function main It is the job of the runtime startup code to perform these tasks specifically e Initialisation of global variables assigned a value when defined e Clearing of non initialised global variables e General setup of registers or processor stat
340. owing error message main obj 8 Fixup overflow in expression loc 0x1FD 0x1FC 1 size 1 value 0x7FC This indicates that the file causing the problem was main obj This would be typically be the output of compiling main c or main as This tells you the file in which you should be looking The next 351 Error and Warning Messages number 8 in this example is the record number in the object file that was causing the problem If you use the DUMP utility to examine the object file you can identify the record however you do not normally need to do this The location loc of the instruction OxI FD the size in bytes of the field in the instruction for the value 1 and the value which is the actual value the symbol represents is typically the only information needed to track down the cause of this error Note that a size which is not a multiple of 8 bits will be rounded up to the nearest byte size i e a 7 bit space in an instruction will be shown as 1 byte Generate an assembler list file for the appropriate module Look for the address specified in the error message 7 07FC 0E21 movlw 33 8 O7FD 6FFC movwf _foo 9 07FE 0012 return and to confirm look for the symbol referenced in the assembler instruction at this address in the symbol table at the bottom of the same file Symbol Table Fri Aug 12 13 17 37 2004 _foo 01FC _main O7FF In this example the instruction causing the problem takes an 8 bit offset into a bank of m
341. p Eee os Ae hee BS ay sea eee 192 COBOS canoa PEGA ASE ee eA eee EEE OE ee EES 193 COS 6 Me ek Soe eS Oe Bee ee ERR Se we RE A See EM Be ee aes 195 COSH 245 Gh edwe bbe a Rede Roe obese amp BR Ed dd 196 CPUTS 25 ce hb eh eee he eae et be ew db be ee eS 197 A he Jee hp Gis Seve hk Bs Uh deh Se edt Bs aes hy Go oak ts HJ hah wre 198 DIV 4 parca ede ee Eee a EMRE A REN RO EERE EEO ES 199 EVAL POLT ees ete dy ede Sad hele Ss o tas a da Be Reo g 200 ERP iy te tne e aaae os a e ah GE des os ip ep Gee Govan sees Bas a St tes ths Os tes Seno 201 PADS oid nk Se ee ee Soe ae oe ee ee wo oe ee 202 FMOD o omy bt ig ay fe donde eet E Gm ee Hen fs dd ne ae eae ee we 203 FLOOR 20 ge bee a 4 ee bee ee Pee ee ede eee eS 204 FREE 2 256 baad lee Ox A ee ee od ee AEF OOS AS wars 205 o acct ma ees ike oy fog Ge seo sagt Sav sts We ea al ay Ge eR Re tee Sok A i 206 GHICH ceart eh ee eS BAA A See SRE ELE ESSE CRA AES 207 GETCHAR coupe Ei ee Re ee oA Oe EE A es 208 GEES oa e poi ts i RS a Ge he Oh Be BI a Rt be 209 GMTIME ace be EGA ASHLEE Eee eee EEE Pee eS 210 DALNUM crag a ee She ee ee ER ee ee A es e a ee A 212 CONTENTS CONTENTS ISDIG e sane ee eR a REE EEE Peal ee ewe 214 IOA IN R a e E R E G 215 LABS 245 o Bee SG on ee BA hee 216 EP veea EE Ae wR Se E Ee Oe ee a aes 217 PN is Rie Set e wy Edie ae Dee ee eee ae eh ae eins amp ees 218 LOCALTIMEB ooo cimas a A he e eS 219 EOG dt eel e esd a eee BGO Gee Be ge Se Be WL Se eh a ALS Was Sh hh Ms 2
342. pe specified in el if sizeof Preprocessor Sizeof was used in a preprocessor if expression but no type was specified The argument to sizeof in a preprocessor expression must be a valid simple type or pointer to a simple type e g if sizeof oops size of what i 0 endif 133 unknown type code 0x in el if sizeof Preprocessor The preprocessor has made an internal error in evaluating a sizeof expression Check for a malformed type specifier This is an internal error Contact HI TECH Software technical support with details 134 syntax error in el if sizeof Preprocessor The preprocessor found a syntax error in the argument to sizeof in a if expression Probable causes are mismatched parentheses and similar things e g if sizeof int 2 oops should be if sizeof int 2 i OxFFFF endif 294 Error and Warning Messages 135 unknown operator in if Preprocessor The preprocessor has tried to evaluate an expression with an operator it does not understand This is an internal error Contact HI TECH Software technical support with details 137 strange character after Preprocessor A character has been seen after the token catenation operator that is neither a letter nor a digit Since the result of this operator must be a legal token the operands must be tokens containing only letters and digits e g the character will not lead to a valid toke
343. pplication 162 cromwell option B 165 C 164 D 163 E 165 F 164 Ikey 164 L 164 M 165 N 163 Okey 164 P 163 V 165 cromwell options 162 cross reference disabling 134 generating 160 list utility 160 cross reference file 111 generation 111 cross reference listings 50 excluding header symbols 160 excluding symbols 161 162 headers 161 output name 161 page length 161 page width 161 cross referencing enabling 135 ctime function 198 DABS directive 127 data psect 86 138 copying 139 data psects 29 data types 67 16 bit integer 71 8 bit integer 71 assembly 117 char 71 floating point 72 int 71 short 71 DB directive 126 debug information 35 44 assembler 112 optimizers and 112 default psect 121 default radix assembly 116 delta PSECT flag 123 delta psect flag 142 dependencies 61 dependency checking 24 device selection 50 directives asm C 92 assembler 121 425 INDEX INDEX div function 199 divide by zero result of 85 doprnt c source file 33 doprnt pre 35 driver command file 21 input files 20 long command lines 21 options 20 single step compilation 23 driver option ERRFORMAT format 51 ERRORS number 51 LANG language 54 MSGFORMAT format 51 NODEL 23 OUTPUT type 56 PASS1 22 24 25 PRE 25 RUNTIME 27 RUNTIME type 29 30 60 WARN level 63 WARNFORMAT format 51 C 24 42 Efile 4
344. preted as a printf style format string and it is not syntactically correct If not corrected this will cause unexpected behaviour at run time e g printf 1 111 oops maybe printf ld 111 326 long int argument required in printf style format string Parser A long argument is required for this format specifier Check the number and order of format speci fiers and corresponding arguments e g printf 31x 2 maybe you meant printf lx 2L 327 long long int argument required in printf style format string Parser A long long argument is required for this format specifier Check the number and order of format specifiers and corresponding arguments e g printf 1lx 2 maybe you meant printf llx 2LL Note that not all HI TECH C compilers provide support for a long long integer type 328 int argument required in printf style format string Parser An integral argument is required for this printf style format specifier Check the number and order of format specifiers and corresponding arguments e g printf d 1 23 wrong number or wrong placeholder 327 Error and Warning Messages 329 double argument required in printf style format string Parser The printf format specifier corresponding to this argument is f or similar and requires a floating point expression Check for missing or extra format specifiers or arguments to printf
345. process Assembly Files The P option causes the assembler files to be preprocessed before they are assembled thus allowing the use of preprocessor directives such as include with assembler code By default assembler files are not preprocessed 2 6 12 Q Quiet Mode This option places the compiler in a quiet mode which suppresses the HI TECH Software copyright notice from being displayed 2 6 13 S Compile to Assembler Code The S option stops compilation after generating an assembler source file An assembler file will be generated for each file passed to the assembler by the code generator The command PICC32 CHIP 32MX360F512L S test c testl c will produce an assembler file called test as which contains the code generated from test c and test1 c This option is particularly useful for checking function calling conventions and signature values when attempting to write external assembly language routines The file produced by this option differs to that produced by the ASMLIST option in that it does not contain op codes or addresses and it may be used as a source file and subsequently passed to the assembler to be assembled 2 6 14 Umacro Undefine a Macro The U option the inverse of the D option is used to undefine predefined macros This option takes the form Umacro The option Udraft for example is equivalent to tundef draft placed at the top of each module compiled using this option 48 PICC32 Comman
346. produce a map file even if it encounters errors which will allow you to use this file to track down the cause of the errors However 1f the linker ultimately reports too many errors then it did not run to completion and the map file will be either not created or not complete You can use the ERRORS option on the command line or as an alternate MPLAB IDE setting to increase the number of errors before the compiler applications give up See Section 2 6 26 for more information on this option 148 Linker and Utilities Map Files 5 9 2 Contents The sections in the map file in order of appearance are as follows e The compiler name and version number e Acopy of the command line used to invoke the linker e The version number of the object code in the first file linked e The machine type e Optionally dependent on the processor and compiler options selected the call graph infor mation e A psect summary sorted by the psect s parent object file e A psect summary sorted by the psect s CLASS e A segment summary e Unused address ranges summary and e The symbol table Portions of an example map file along with explanatory text are shown in the following sections 5 9 2 1 General Information At the top of the map file is general information relating to the execution of the linker When analysing a program always confirm the compiler version number shown in the map file if you have more than one compiler version
347. ptions Option Effect ADDRESSING Set address fields in all hexmate options to use word addressing or other BREAK Break continuous data so that a new record begins at a set address CK Calculate and store a checksum value FILL Program unused locations with a known value FIND Search and notify if a particular code sequence is detected FIND DELETE Remove the code sequence if it is detected use with caution FIND REPLACE Replace the code sequence with a new code sequence FORMAT Specify maximum data record length or select INHX variant HELP Show all options or display help message for specific option LOGFILE Save hexmate analysis of output and various results to a file Ofile Specify the name of the output file SERIAL Store a serial number or code sequence at a fixed address SIZE Report the number of bytes of data contained in the resultant hex image STRING Store an ASCII string at a fixed address STRPACK Store an ASCII string at a fixed address using string packing W Adjust warning sensitivity Prefix to any option to overwrite other data in its address range if necessary 167 Hexmate Linker and Utilities will use myfile hex as input but only process data which is addressed within the range 100h 1FFh inclusive to be read from myfile hex An address shift can be applied with the specification sOffset If an address shif
348. r When running in Lite mode the advanced Omniscient Code Generation OCG features are disabled This will result in much larger code than would be produced when running in PRO mode 1274 delay exceeds maximum limit of cycles Code Generator The argument to the in line delay routine _delay is limited to the maximum size indicated Use the routine consequtively or place it is a loop to acheive the desired delay period 1284 malformed mapfile while generating summary CLASS expected but not found Driver This is an internal compiler error Contact HI TECH Software technical support with details 1285 malformed mapfile while generating summary no name at position Driver This is an internal compiler error Contact HI TECH Software technical support with details 1286 malformed mapfile while generating summary no link address at position Driver This is an internal compiler error Contact HI TECH Software technical support with details 1287 malformed mapfile while generating summary no load address at position Driver This is an internal compiler error Contact HI TECH Software technical support with details 412 Error and Warning Messages 1288 malformed mapfile while generating summary no length at position Driver This is an internal compiler error Contact HI TECH Software technical support with details 0 delete what Libr The librarian requires one or more modules to be listed for deleti
349. r The members of structures and unions may not be objects of type bit but bit fields are fully supported Structures and unions may be passed freely as function arguments and return values Pointers to structures and unions are fully supported 3 3 8 1 Bit fields in Structures HI TECH C PRO for the PIC32 MCU Familyfully supports bit fields in structures bit fields are always allocated within 32 bit words The first bit defined will be the least signifi cant bit of the word in which it will be stored When a bit field is declared it is allocated within the current 32 bit unit if it will fit otherwise a new word is allocated within the structure bit fields can never cross the boundary between 32 bit allocation units For example the declaration struct 73 Supported Data Types and Variables C Language Features unsigned Tor Ly unsigned dummy 30 unsigned hae ag AS foo will produce a structure occupying 4 bytes If foo was ultimately linked at address 10H the field lo will be bit 0 of address 10H hi will be bit 7 of address 13H The least significant bit of dummy will be bit 1 of address 10H and the most significant bit of dummy will be bit 6 of address 13h Unnamed bit fields may be declared to pad out unused space between active bits in control registers For example if dummy is never used the structure above could have been declared as struct unsigned To unsigned 30 unsigned ae sh ls foo If a bi
350. r a non maskable interrupt and invoke Non maskable interrupts are sup it s handler if necessary ported soft Test for a soft reset condition and invoke the Soft interrupts are enabled applicable interrupt function cp0 Initialise the system coprocessor See Section The system coprocessor is initial Lido ized gpr Initialise some general purpose registers See Some general purpose registers Section 2 3 2 4 are initialised with special values icache Whether instruction caching is used or not Instruction caching is used stack Reserve memory for the stack and initialise Will reserve as much memory the stack pointer register 29 accordingly See as possible for the stack unless Section 2 3 2 5 specified otherwise heap Reserve memory for the heap See Section Will reserve as much memory pe as possible for the heap unless specified otherwise perform Configures the device for optimal perfor Using either the maximum or mance Supplying an argument will initialise nominated frequency the driver the device to perform at that frequency in Hz will initialise the device See Section 2 3 2 7 plib Compiler links the peripheral libraries Other Compiler links the peripheral li than lt htc h gt no other header files need to be braries included to use the functions in these libraries By default this option is not set 2 6 49 SCANDEP Scan for Dependencies When this option is used a dep dependency file is
351. r keyword was found following a statement with no terminating semicolon e g while a b a oops where is the semicolon error is flagged here 324 Error and Warning Messages Note Omitting a semicolon from statements not preceding a close brace or keyword typically results in some other error being issued for the following code which the parser assumes to be part of the original statement 315 expected Parser An opening brace was expected here This error may be the result of a function definition missing the opening brace e g oops no opening brace after the prototype void process char c return max c 10 2 error flagged here 316 expected Parser A closing brace was expected here This error may be the result of a initialized array missing the closing brace e g char carray 4 1 2 3 4 oops no closing brace 317 expected Parser An opening parenthesis was expected here This must be the first token after a while for if do or asm keyword e g if a b should be if a b b 0 318 string expected Parser The operand to an asm statement must be a string enclosed in parentheses e g asm nop that should be asm nop 319 while expected Parser The keyword while is expected at the end of a do statement e g 325 Error and Warning Messages do func itt do the block wh
352. random value e g void main void int a if a oops a has never been assigned a value process 749 unknown register name used with pragma Linker This is an internal compiler error Contact HI TECH Software technical support with details 372 Error and Warning Messages 750 constant operand to ll or amp amp Code Generator One operand to the logical operators or amp amp is a constant Check the expression for missing or badly placed parentheses This message may also occur if the global optimizer is enabled and one of the operands is an auto or static local variable whose value has been tracked by the code generator e g int a a 6 if a b a is 6 therefore this is always true bt t 751 arithmetic overflow in constant expression Code Generator A constant expression has been evaluated by the code generator that has resulted in a value that is too big for the type of the expression The most common code to trigger this warning is assignments to signed data types For example signed char c c OxFF As a signed 8 bit quantity c can only be assigned values 128 to 127 The constant is equal to 255 and is outside this range If you mean to set all bits in this variable then use either of c 0x0 c l which will set all the bits in the variable regardless of the size of the variable and without warning This warning can also be triggered by intermediate v
353. range Code Generator This is the result of comparing a bitfield with a value when the value is out of range of the bitfield For example comparing a 2 bit bitfield to the value 5 will never be true as a 2 bit bitfield has a range from 0 to 3 e g struct unsigned mask 2 mask can hold values 0 to 3 value int compare void return value mask 6 test can 755 divide by zero Code Generator A constant expression that was being evaluated involved a division by zero e g a 0 divide by 0 was this what you were intending 374 Error and Warning Messages 757 constant conditional branch Code Generator A conditional branch generated by an if for while statement etc always follows the same path This will be some sort of comparison involving a variable and a constant expression For the code generator to issue this message the variable must have local scope either auto or static local and the global optimizer must be enabled possibly at higher level than 1 and the warning level threshold may need to be lower than the default level of 0 The global optimizer keeps track of the contents of local variables for as long as is possible during a function For C code that compares these variables to constants the result of the comparison can be deduced at compile time and the output code hard coded to avoid the comparison e g int a b a 5 this can never be false always perform
354. re details 2 1 1 Long Command Lines The PICC32 driver is capable of processing command lines exceeding any operating system limita tion To do this the driver may be passed options via a command file The command file is read by using the symbol which should be immediately followed i e no intermediate space character by the name of the file containing the command line arguments The file may contain blank lines which are simply skipped by the driver The command line arguments may be placed over several lines by using a space and backslash character for all non blank lines except for the last line The use of a command file means that compiler options and project filenames can be stored along with the project making them more easily accessible and permanently recorded for future use TUT RIAL USING COMMAND FILES A command file xyz cmd is constructed with your favorite text editor and contains both the options and file names that are required to compile your project as follows chip 32MX360F512L m Y opt all g main c isr c After it is saved the compiler may be invoked with the command PICC32 xyz cmd 21 The Compilation Sequence PICC32 Command line Driver Figure 2 1 Flow diagram of the initial compilation sequence e e e e CPP dae pre Loscdoosocesosonlooosess d O 2 P1 PASSI pi cco IO O E Das generator
355. rian Linker and Utilities Table 5 2 Librarian command line options Option Effect Pwidth specify page width W Suppress non fatal errors Table 5 3 Librarian key letter commands Key Meaning Replace modules Delete modules Extract modules List modules List modules with symbols Re order modules ojajB3 X ajBK 5 10 2 Using the Librarian The librarian program is called LIBR and the format of commands to it is as follows LIBR options k file lib file obj Interpreting this LIBR is the name of the program options is zero or more librarian options which affect the output of the program k is a key letter denoting the function requested of the librarian replacing extracting or deleting modules listing modules or symbols file 11bis the name of the library file to be operated on and file obj is zero or more object file names The librarian options are listed in Table 5 2 The key letters are listed in Table 5 3 When replacing or extracting modules the file obj arguments are the names of the modules to be replaced or extracted If no such arguments are supplied all the modules in the library will be replaced or extracted respectively Adding a file to a library is performed by requesting the librarian to replace it in the library Since it is not present the module will be appended to the library If the r key is used and the library does not exist it will be crea
356. rings on two lines will be concatenated Check that this is the desired result e g char cp hi there this is okay but is it what you had intended 337 line does not have a newline on the end Parser The last line in the file is missing the newline operating system dependent character from the end Some editors will create such files which can cause problems for include files The ANSI C standard requires all source files to consist of complete lines only 338 can t create file Any The application tried to create or open the named file but it could not be created Check that all file pathnames are correct 339 initializer in extern declaration Parser A declaration containing the keyword extern has an initialiser This overrides the extern storage class since to initialise an object it is necessary to define i e allocate storage for it e g extern int other 99 if it s extern and not allocated storage how can it be initialized 340 string not terminated by null character Parser A char array is being initialized with a string literal larger than the array Hence there is insufficient space in the array to safely append a null terminating character e g char foo 5 12345 the string stored in foo won t have a null terminating i e foo 1 Aa 130 es 134 329 Error and Warning Messages 343 implicit return at end of non void function Par
357. rmats which are used by common PROM programmers and in circuit emulators The default behaviour of the PICC32 command is to produce ELF DWARF and Intel HEX output If no output filename or type is specified PICC32 will produce an ELF DWAREF and Intel HEX file with the same base name as the first source or object file specified on the command line Table 2 12 shows the output format options available with PICC 32 The File Type column lists the filename extension which will be used for the output file 2 4 2 Symbol Files The PICC32 G option tells the compiler to produce several symbol files which can be used by debuggers and simulators to perform symbolic and source level debugging Using the IDE option may also enable symbol file generation as well The G option produces an absolute symbol files which contain both assembler and C level information This file is produced by the linker after the linking process has ben completed If no symbol filename is specified a default filename of file sym will be used where file is the basename of the first source file specified on the command line For example to produce a symbol file called test sym which includes C source level information 35 Compiler Messages PICC32 Command line Driver PICC32 CHIP 32MX360F512L Gtest sym test c init c This option will also generate other symbol files for each module compiled These files are produced by the code generator and do not contain absolute
358. rning pragma It is also possible to change the type of some messages This is only possible by the use of the warning pragma and only affects messages generated by the parser or code generator The position of the pragma is only significant for the parser i e a parser message number may have its type changed then reverted back around a section of the code to target specific instances of the message Specific instances of a message produced by the code generator cannot be individually controlled The pragma will remain in force during compilation of the entire module TUTORIAL The following shows the warning produced in the previous example being converted to an error for the instance in the function main void main void pragma warning error 348 near int c pragma warning warning 348 etc int rv int a near int c etc Compilation of this code would result in an error and as with any error this will force compilation to cease after the current module has concluded or the maximum error count has been reached 3 12 Linking Programs The compiler will automatically invoke the linker unless requested to stop after producing assembly code PICC32 S option or object code PICC32 C option HI TECH C by default generates Intel HEX Use the OUTPUT option to specify a different output format After linking the compiler will automatically generate a memory usage map which shows the address used
359. rocessor A maximum of 7 directories may be specified for the preprocessor to search for include files The number of directories specified with the driver is too great 148 too many arguments for preprocessor macro Preprocessor A macro may only have up to 31 parameters as per the C Standard 149 preprocessor macro work area overflow Preprocessor The total length of a macro expansion has exceeded the size of an internal table This table is normally 32768 bytes long Thus any macro expansion must not expand into a total of more than 32K bytes 150 illegal __ preprocessor macro Preprocessor This is an internal compiler error Contact HI TECH Software technical support with details 151 too many arguments in preprocessor macro expansion Preprocessor There were too many arguments supplied in a macro invocation The maximum number allowed is 31 152 bad dp nargs in openpar c Preprocessor This is an internal compiler error Contact HI TECH Software technical support with details 296 Error and Warning Messages 153 out of space in preprocessor macro argument expansion Preprocessor A macro argument has exceeded the length of an internal buffer This buffer is normally 4096 bytes long 155 work buffer overflow conatenating Preprocessor This is an internal compiler error Contact HI TECH Software technical support with details 156 work buffer overflow Preprocessor Th
360. rom being included in the listing output See also the COND control in Section 4 3 11 6 4 3 11 11 NOEXPAND NOEXPAND disables macro expansion in the listing file The macro call will be listed instead See also the EXPAND control in Section 4 3 11 7 Assembly macro are discussed in Section 4 3 10 15 4 3 11 12 NOLIST This control turns the listing output off from this point onward See also the LIST control in Section 4 3 11 9 4 3 11 13 NOXREF NOXREF will disable generation of the raw cross reference file See also the XREF control in Section 4 3 11 18 134 Macro Assembler HI TECH C Assembly Language 43 11 14 PAGE PAGE causes a new page to be started in the listing output A Control L form feed character will also cause a new page when encountered in the source 43 11 15 SPACE The SPACE control will place a number of blank lines in the listing output as specified by its param eter 4 3 11 16 SUBTITLE SUBTITLE defines a subtitle to appear at the top of every listing page but under the title The string should be enclosed in single or double quotes See also the TITLE control in Section 4 3 11 17 4 3 11 17 TITLE This control keyword defines a title to appear at the top of every listing page The string should be enclosed in single or double quotes See also the SUBTITLE control in Section 4 3 11 16 4 3 11 18 XREF XREF is equivalent to the driver command line option CR see Section 2 6 22 It causes the asse
361. ror and Warning Messages 939 no file arguments Driver The driver has been invoked with no input files listed on its command line If you are getting this message while building through a third party IDE perhaps the IDE could not verify the source files to compile or object files to link and withheld them from the command line 940 bit checksum placed at Objtohex Presenting the result of the requested checksum calculation 941 bad assignment USAGE Hexmate An option to Hexmate was incorrectly used or incomplete Follow the usage supplied by the message and ensure that that the option has been formed correctly and completely 942 unexpected character on line of file Hexmate File contains a character that was not valid for this type of file the file may be corrupt For example an Intel hex file is expected to contain only ASCII representations of hexadecimal digits colons and line formatting The presence of any other characters will result in this error 944 data conflict at address h between and Hexmate Sources to Hexmate request differing data to be stored to the same address To force one data source to override the other use the specifier If the two named sources of conflict are the same source then the source may contain an error 945 checksum range h to h contained an indeterminate value Hexmate The range for this checksum calculation contained a value that could n
362. s this results in two volatile qualifiers volatile vint very_vol 259 can t be qualifed both far and near Parser It is illegal to qualify a type as both far and near e g far near int spooky oops choose far or near not both 315 Error and Warning Messages 260 undefined enum tag Parser This enum tag has not been defined e g enum WHAT what a definition for WHAT was never seen 261 struct union member redefined Parser This name of this member of the struct or union has already been used in this struct or union e g struct int a int b int a oops a different name is required here input 262 struct union redefined Parser A structure or union has been defined more than once e g struct int a ms struct int a ms was this meant to be the same name as above 263 members can t be functions Parser A member of a structure or a union may not be a function It may be a pointer to a function e g struct int a int get int should be a pointer int get int object 264 bad bitfield type Parser A bitfield may only have a type of int signed or unsigned e g 316 Error and Warning Messages struct FREG char b0 1 these must be part of an int not char char 6 char b7 1 freg 265 integer constant expected Parser A colon appearing after a member name in a structur
363. s int c char strichr const char s int c Description The strehr function searches the string s for an occurrence of the character c If one is found a pointer to that character is returned otherwise NULL is returned The strichr function is the case insensitive version of this function Example include lt strings h gt include lt stdio h gt void main void static char temp Here it is char c s if strchr temp c printf Character c was found in string n c else printf No character was found in string See Also strrchr strlen stremp Return Value A pointer to the first match found or NULL if the character does not exist in the string 251 Library Functions Note Although the function takes an integer argument for the character only the lower 8 bits of the value are used 252 Library Functions STRCMP STRICMP Synopsis include lt string h gt int strcmp const char sl const char s2 int stricmp const char sl const char s2 Description The stremp function compares its two null terminated string arguments and returns a signed integer to indicate whether s1 is less than equal to or greater than s2 The comparison is done with the standard collating sequence which is that of the ASCII character set The stricmp function is the case insensitive version of this function Example include lt string h gt in
364. s above the upper limit of RAM since RAM and const pointers use this address to determine if an access to ROM or RAM is required See Section 3 3 11 80 C Language Features Functions 3 5 Functions 3 5 1 Absolute Functions The generated code associated with a function can be placed at an absolute address This can be accomplished by using an address construct in a similar fashion to that used with absolute vari ables The following example of an absolute function which will place the function label and first assembly instruction corresponding to the function at address 400h int mach_status int mode 0x400 function body Using this construct with interrupt functions will not alter the position of the interrupt context saving code that preceeds the code associated with the interrupt function body Note also that the address specified will be interpreted as a virtual address and not a physical address 3 5 2 Function Argument Passing The method used to pass function arguments depends on the size of the argument or arguments and the degree of optimisation specified The compiler is free to choose the most optimal combination of passing arguments in registers or on the stack Only argument values of a type equal to or less than 4 bytes are candidates for being passed in a register Depending on the ISA of a given function it will be restricted to a subset of registers in which arguments can be passed to it mips32r2 func
365. s generating a log file it will contain the results of all searches FIND accepts whole bytes of hex data from 1 to 8 bytes in length Optionally FIND can be used in conjunction with REPLACE or DELETE as described below 171 Hexmate Linker and Utilities 5 14 1 8 FIND DELETE If DELETE is used in conjunction with a FIND option and a sequence is found that matches the FIND criteria it will be removed This function should be used with extreme caution and is not recommended for removal of executable code 5 14 1 9 FIND REPLACE REPLACE Can only be used in conjunction with a FIND option Code sequences that matched the FIND criteria can be replaced or partially replaced with new codes The usage for this sub option is FIND REPLACE Code mMask where e Code is a little endian hexadecimal code to replace the sequences that match the FIND crite ria e Mask is an optional bit mask to specify which bits within Code will replace the code sequence that has been matched This may be useful if for example it is only necessary to modify 4 bits within a 16 bit instruction The remaining 12 bits can masked and be left unchanged 5 14 1 10 FORMAT The FORMAT option can be used to specify a particular variant of INHX format or adjust maximum record length The usage of this option is FORMAT Typel Length where e Type specifies a particular INHX format to generate e Length is optional and sets the max
366. s in a human readable format line This standard format is perfectly acceptable to a person reading the error output but is not generally usable with environments which support compiler error handling The following sections indicate how this option may be used in such situations This option allows the exact format of printed error messages to be specified using special place holders embedded within a message template See Section 2 5 for full details of the messaging system employed by PICC32 This section is also applicable to the WARNFORMAT and MSGFORMAT options which adjust the format of warning and advisory messages respectively See Section 2 6 33 for the appropriate option to change the message language 2 6 26 ERRORS number Maximum Number of Errors This option sets the maximum number of errors each compiler application as well as the driver will display before stopping By default up to 20 error messages will be displayed See Section 2 5 for full details of the messaging system employed by PICC32 51 PICC32 Driver Option Descriptions PICC32 Command line Driver Table 2 6 Supported IDEs Suboption IDE hitide HI TECH Software s HI TIDE mplab Microchip s MPLAB 2 6 27 FILL opcode Fill Unused Program Memory This option allows specification of a hexadecimal opcode that can be used to fill all unused program memory locations with a known code sequence Multi byte codes should
367. s tewie veds 114 433 Statement Formats o o eo se eel gk ee a AA 114 ASA Characters lt eni ee ba Pa eed whe k da aR E i RS A 114 43 8 1 Delmer sesar rar OR Boe AA 114 454 2 special CNaracie o is A e oe hh abe o4 114 Bee NCOMMAGIES a a o dom te o Soe des 114 4 3 5 1 Special Comment Strings 116 AO COMME dl RA E E 116 4 3 6 1 Numeric Constants ere e ra saree ess esa 116 4 3 6 2 Character Constants and Strings 117 A ls e A ee Se he a A eS EE Re ee 117 4 311 Signiticance of Identifiers gt c s o oie keepe ee sa e e 117 4 3 7 2 Assembler Generated Identifiers 118 43 7 3 Symbolic Labels sos scs e w be eee RS RE EO 118 45 8 EXPIESSIONS 6 se ase he a Se eee 118 439 Program Sections s c acros lk a en Rae ae e o 120 4 5 10 Assembler Directives ic 2444 64 e e ba ER SE RS eS 121 435041 GEOBAL 6 54 6 6 eaaa es ERR ee A AO 121 ADO BND E sede as es tee a ie ve eg ae Rie Sia A Se hace a Spas os 121 ES PREG ln tS oe Ge doe et Pee ea tek bee Gee A 121 43104 ORG ged ga Bae bb RAG Gee eS be PS bb bios 124 45 105 EQU osa nee eae Be ae eR eal a eae 125 43006 SEY oi 6 eb a O Bae a AS Bs 126 43 107 DB ic eee ee SRAM RHA EER EA ee Be ee 126 LLIOS DH o ven ee ee Ee RY ee A 126 AOS DSIRE ee doe g hice bh ok Be te ee Bie ye Oe Se ee a eas 126 ES JOAN DSTRA roots eee ea dr Gee A 126 435 S011 DW sce tb a Bae bb DAG Gee bes be PS dbo 126 AIII DS oia a EA
368. sect 30 86 138 clearing 138 byte addresses 168 C standard libraries 27 28 ceil function 192 cgets function 193 char types 71 character constants 69 assembly 117 checksum endianism 50 169 checksum specifications 158 checksums 50 165 169 algorithms 50 169 424 endianism 50 169 chipinfo files 66 111 class PSECT flag 123 classes 141 address ranges 141 boundary argument 146 upper address limit 146 clearing of variables 30 clib suboption 27 COD file 56 command files 21 command line driver 19 command lines HLINK long command lines 148 long 21 157 verbose option 49 compiler errors format 38 compiler generated psects 85 compiler generate input files 26 compiling to assembly file 48 to object file 42 COND assembler contro 133 COND assembler control 133 conditional assembly 127 config psect 86 configuration word 86 configuration fuses 66 417 console I O functions 107 const psect 86 const qualifier 75 constants assembly 116 C specifiers 67 character 69 string see string literals context saving INDEX INDEX in line assembly 101 copyright notice 48 cos function 195 cosh function 196 cpO qualifier 77 cputs function 197 creating libraries 156 creating new 85 CREF application 111 160 CREF option Fprefix 160 Hheading 161 Llen 161 Ooutfile 161 Pwidth 161 Sstoplist 161 Xprefix 162 CREF options 160 cromwell a
369. ser A function which has been declared to return a value has an execution path that will allow it to reach the end of the function body thus returning without a value Either insert a return statement with a value or if the function is not to return a value declare it void e g int mydiv double a int b if b 0 return a b what about when b is 0 warning flagged here 344 non void function returns no value Parser A function that is declared as returning a value has a return statement that does not specify a return value e g int get_value void if flag return val return what is the return value in this instance 345 unreachable code Parser This section of code will never be executed because there is no execution path by which it could be reached e g while 1 how does this loop finish process flag FINISHED how do we get here 346 declaration of hides outer declaration Parser An object has been declared that has the same name as an outer declaration i e one outside and preceding the current function or block This is legal but can lead to accidental use of one variable when the outer one was intended e g 330 Error and Warning Messages int input input has filescope void process int a int input local blockscope input a input this will use the local variable Is this right 347 external declarati
370. seudo op is used to enforce link time calling convention checking Signature checking and the SIGNAT pseudo op are discussed in more detail later in this chapter Note that in order for assembly language functions to work properly they must look in the right place for any arguments passed and must correctly set up any return values Local variable allocation via the FNSIZE directive argument and return value passing mechanisms are discussed in the Section 4 7 and should be understood before attempting to write assembly language routines 91 Mixing C and Assembly Code C Language Features 3 10 2 asm endasm and asm PIC32 instructions may also be directly embedded in line into C code using the directives asm endasm or the statement asm The asm and endasm directives are used to start and end a block of assembly instructions which are to be embedded into the assembly output of the code generator The asm and endasm construct is not syntactically part of the C program and thus it does not obey normal C flow of control rules however you can easily include multiple instructions with this form of in line assembly The asm statement is used to embed a single assembler instruction This form looks and be haves like a C statement however each instruction must be encapsulated within an asm statement You should not use a asm block within any C constructs such as if while do etc In these cases use only the asm form
371. specific const int out 1234 out is read only out 0 oops writing to a read only object 365 pointer to non static object returned Parser This function returns a pointer to a non static e g auto variable This is likely to be an error since the storage associated with automatic variables becomes invalid when the function returns e g char get_addr void char c returning this is dangerous the pointer could be dereferenced return c 366 operands of not same pointer type Parser The operands of this operator are of different pointer types This probably means you have used the wrong pointer but if the code is actually what you intended use a typecast to suppress the error message 336 Error and Warning Messages 367 identifier is already extern can t be static Parser This function was already declared extern possibly through an implicit declaration It has now been redeclared static but this redeclaration is invalid void main void at this point the compiler assumes set is extern set 10L 6 now it finds out otherwise static void set long a int b PORTA a b 368 array dimension on ignored Preprocessor An array dimension on a function parameter has been ignored because the argument is actually converted to a pointer when passed Thus arrays of any size may be passed Either remove the dimension from the parame
372. spects of the code contained in this module and its effect on program operation If you require any special initialization to be performed immediately after reset you should use the powerup routine feature decsribed later in Section 2 3 3 2 3 2 1 Initialization of Data psects One job of the runtime startup code is ensure that any initialized variables contain their initial value before the program begins execution Initialized variables are those which are not auto objects and which are assigned an initial value in their definition for example input in the following example int input 88 void main void Such initialized objects have two components their initial value stored in a psect destined for non volatile memory i e placed in the HEX file and space for the variable in RAM psect where the variable will reside and be accessed during program execution The actual initial values are placed in a psect called idata Space is reserved for the runtime location of initialized variables in a psect called rdata This psect does not contribute to the output file and consitutes a reservation of space in the RAM once the program is running The runtime startup code performs a block copy of the values from the idata to the rdata psect so that the RAM variables will contain their initial values before main is executed Each location in the idata psect is copied to the corresponding place in the rdata psect The block copy of the data psec
373. ster 2 v0 See also 3 5 3 Register 28 gp is initialised in the runtime startup code with the centre address of KSEG1 DRM to allow more efficient access of data and bss objects in RAM Register 29 sp serves as the program s stack pointer and is initialised in the runtime startup code The compiler does not make use of the dedicated stack frame pointer register Register 30 fp s8 is initialised in the runtime startup code with the centre address of the const psect to allow more efficient access of constant data in ROM Therefore the const psect is limited by a maximum size padding included of 64KB Where programs require more constant data the excess will be allocated to the constfar psect See 2 6 48 for more information on the RUNTIME option Register 31 ra is used to store the return address of the most recent function call In leaf functions functions which occur only as leaf nodes in all call graphs the contents of this 82 C Language Features Operators register will always contain the return address from that function In non leaf functions the contents of the register is preserved on the stack 3 7 Operators HI TECH C PRO for the PIC32 MCU Family supports all the ANSI operators The exact results of some of these are implementation defined The following sections illustrate code produced by the compiler 3 7 1 Integral Promotion When there is more than one operand to an operator they typically must be of exactly the s
374. sting See Section 4 10 for more information Cchipinfo Specify the chipinfo file to use The chipinfo file is called pic32 ini and can be found in the DAT directory of the compiler distribution E fileldigit The default format for an error message is in the form filename line message where the error of type message occurred on line line ofthe file filename The E option with no argument will make the assembler use an alternate format for error and warning messages Use of the option in this form has a similar effect as the same option used with command line driver See Section 2 5 for more information Specifying a digit as argument has a similar effect only it allows selection of pre set message formats Specifying a filename as argument will force the assembler to direct error and warning messages to a file with the name specified Flength By default when an assembly list file is requested see assembler option L the listing format is pageless i e the assembly listing output is continuous The output may be formatted into pages of varying lengths Each page will begin with a header and title if specified The F option allows a page length to be specified A zero value of length implies pageless output The length is specified in a number of lines H Particularly useful in conjunction with the A or L ASPIC32 options this option specifies that output constants should be shown as hexadecimal values rather than decimal values
375. stristr 267 strlen 257 strncat 258 strncmp 260 strncpy 262 strnicmp 260 strpbrk 264 strrchr 265 strrichr 265 strspn 266 strstr 267 strtod 268 strtok 272 strtol 270 tan 274 tanh 196 time 275 toascii 277 tolower 277 toupper 277 trunc 278 ungetc 279 280 ungetch 281 utoa 282 va_arg 283 va_end 283 va_start 283 vscanf 242 xtol 285 limit PSECT flag 123 limiting number of error messages 51 link addresses 139 144 linker 137 INDEX INDEX command files 148 command line arguments 139 148 invoking 148 long command lines 148 passes 155 symbols handled 138 linker defined symbols 107 linker errors aborting 143 undefined symbols 144 linker option Aclass low high 141 146 Cpsect class 141 Dsymfile 142 Eerrfile 142 F 142 Gspec 142 H symfile 143 Hsymfile 143 I 144 Jerrcount 143 K 143 L 144 LM 144 Mmapfile 144 N 144 Nc 144 Ns 144 Ooutfile 144 Pspec 144 Qprocessor 146 Sclass limit bound 146 Usymbol 147 Vavmap 147 Wnum 147 X 147 Z 147 linker options 139 adjusting use driver 45 numbers in 140 linking programs 104 LIST assembler control 134 list files assembler 49 little endian format 67 71 72 169 load addresses 139 144 LOCAL directive 118 129 local PSECT flag 124 local psects 138 local symbols 49 suppressing 112 147 local variables 79 auto 79 static 79 loca
376. sum result A negative width will store the result in little endian byte order Result widths from one to four bytes are permitted offset nnnn An initial value or offset to be added to this checksum algorithm n Select one of the checksum algorithms implemented in hexmate The selectable al gorithms are described in Table 5 10 2 6 20 CHIP processor Define Processor This option can be used to specify the target processor for the compilation To see a list of supported processors that can be used with this option use the CHIPINFO option described in Section 2 6 21 See also Section 4 3 10 20 for information on setting the target processor from within assembly files 2 6 21 CHIPINFO Display List of Supported Processors The CHIPINFO option simply displays a list of processors the compiler supports The names listed are those chips defined in the chipinfo file and which may be used with the CHIP option 2 6 22 CR file Generate Cross Reference Listing The CR option will produce a cross reference listing If the file argument is omitted the raw cross reference information will be left in a temporary file leaving the user to run the CREF utility If a filename is supplied for example CR test crf PICC32 will invoke CREF to process the cross reference information into the listing file in this case test crf If multiple source files are to be included in the cross reference listing all must be compiled and
377. t Flength Specify listing form length 66 H Output hex values for constants Decimal values I List macro expansions Don t list macros L listfile Produce listing No listing 0 Perform optimization No optimization Ooutfile Specify object name srcfile obj Pprocessor Define the processor R Specify non standard ROM Twidth Specify listing page width 80 V Produce line number info No line numbers Wlevel Set warning level threshold 0 X No local symbols in OBJ file 4 2 Assembler Options The command line options recognised by ASPIC32 are as follows 110 Macro Assembler Assembler Options A An assembler file with an extension opt will be produced if this option is used This is useful when checking the optimized assembly produced using the 0 assembler option Thus if both A and O are used with an assembly source file the file will be optimized and rewritten with out the usual conversion to an object file The output file when this option is used is a valid assembly file that can be passed to the as sembler This differs to the assembly list file produced by the assembler when the L assembler option is used C Across reference file will be produced when this option is used This file called srcfile crf where srcfile is the base portion of the first source file name will contain raw cross refer ence information The cross reference utility CREF must then be run to produce the formatted cross reference li
378. t character matches first part of a default linker option then that default linker option is replaced by the option specified by the L TUTORIAL REPLACING DEFAULT LINKER OPTIONS In a particular project the psect entry is used but the programmer needs to ensure that this psect is positioned above the address 800h This can be achieved by adjusting the default linker option that positions this psect First a map file is generated to determine how this psect is normally allocated memory The Linker command line in the map file indicates that this psect is nor mally linked using the linker option pentry CODE Which places entry anywhere in the memory defined by the CODE class The program mer then re links the project but now using the driver option L pentry CODE 800h to ensure that the psect is placed above 800h Another map file is generated and the Linker command line section is checked to ensure that the option was recieved and executed by the linker Next the address of the psect entry is noted in the psect lists that appear later in the map file See Section 5 9 for more information on the contents of the map file If there are no characters following the first character in the L option then any matching default linker option will be deleted For example L pfirst will remove any default linker option that begins with the string pfirst No warning is generated if such a default linker option cannot be found TUTORI
379. t they may be used anywhere in the module in which they are defined They may be used by code above their definition To make a label accessable in other modules use the GLOBAL directive See Section 4 3 10 1 for more information 4 3 8 Expressions The operands to instructions and directives are comprised of expressions Expressions can be made up of numbers identifiers strings and operators Operators can be unary one operand e g not or binary two operands e g The operators allowable in expressions are listed in Table 4 6 The usual rules governing the syntax of expressions 118 Macro Assembler HI TECH C Assembly Language Table 4 6 ASPIC32 operators Operator Purpose Example 7 Multiplication movlw 4 33 Addition bra 1 Subtraction DB 5 2 Division movlw 100 4 or eg Equality IF inp eq 66 gt or gt Signed greater than IF inp gt 40 gt or ge Signed greater than or equal to IF inp ge 66 lt orlt Signed less than IF inp lt 40 lt or le Signed less than or equal to IF inp le 66 lt gt or ne Signed not equal to IF inp lt gt 40 low Low byte of operand ovlw low inp high High byte of operand ovlw high 1008h highword High 16 bits of operand DW highword inp mod Modulus ovlw 77 mod 4 amp Bitwise AND clrf inps0ffh A Bitwise XOR exclusive or ovlw inp 80 Bitwise OR ovlw inp 1 not Bitwise complement ovlw not
380. t HI TECH Software technical support with details 1059 rewrite loop Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 1081 static initialization of persistent variable Parser Code Generator A persistent variable has been assigned an initial value This is somewhat contradictory as the initial value will be assigned to the variable during execution of the compiler s startup code however the persistent qualifier requests that this variable shall be unchanged by the compiler s startup code 1082 size of initialized array element is zero Code Generator This is an internal compiler error Contact HI TECH Software technical support with details 1088 function pointer is used but never assigned a value Code Generator A function call involving a function pointer was made but the pointer was never assigned a target address e g void fp int fp 23 oops what function does fp point to 1089 recursive function call to Code Generator A recursive call to the specified function has been found The call may be direct or indirect using function pointers and may be either a function calling itself or calling another function whose call graph includes the function under consideration 402 Error and Warning Messages 1090 variable is not used Code Generator This variable is declared but has not been used by the progra
381. t field is declared in a structure that is assigned an absolute address no storage will be allocated for the structure Absolute structures would be used when mapping a structure over a register to allow a portable method of accessing individual bits within the register A structure with bit fields may be initialised by supplying a comma separated list of initial values for each field For example struct unsigned To niels unsigned mid 30 unsigned his esL foo 1 8 0 3 3 8 2 Structure and Union Qualifiers HI TECH C PRO for the PIC32 MCU Family supports the use of type qualifiers on structures When a qualifier is applied to a structure all of its members will inherit this qualification In the following example the structure is qualified const const struct int number int ptr record 0x55 amp i 74 C Language Features Supported Data Types and Variables In this case the structure will be placed into the program space and each member will obviously be read only Remember that all members must be initialized if a structure is const as they cannot be initialized at runtime If the members of the structure were individually qualified const but the structure was not then the structure would be positioned into RAM but each member would be read only Compare the following structure with the above struct const int number int const ptr record 0x55 amp i 3 3 9 Standard Type Qualifi
382. t for identifiers but not mnemonics and reserved words Tabs are treated as equivalent to spaces 4 3 4 1 Delimiters All numbers and identifiers must be delimited by white space non alphanumeric characters or the end of a line 4 3 4 2 Special Characters There are a few characters that are special in certain contexts Within a macro body the character amp is used for token concatenation To use the bitwise amp operator within a macro body escape it by using amp amp instead In a macro argument list the angle brackets lt and gt are used to quote macro arguments 4 3 5 Comments An assembly comment is initiated with a semicolon that is not part of a string or character constant If the assembly file is first processed by the C preprocessor see Section 2 6 11 then it may also contain C or C style comments using the standard and syntax 114 Macro Assembler HI TECH C Assembly Language VARIANT INTERPRETATION ADD rd rt ADD rd rd rt ADDU rd rt ADDU rd rd rt ADDI rt immediate ADDI rt rt immediate ADDIU rt immediate ADDIU rt rt immediate AND rd rt AND rd rd rt ANDI rt immediate ANDI rt rt immediate CLO rd CLO rd rd CLZ rd CLZ rd rd MUL rd rt UL rd rd rt NEG rd EG rd rd NEGU rd EGU rd rd NOR rd rt OR Edy Ed Ht NOT rd OT rd rd OR rd rt OR E
383. t is a conventional macro argument list in the case or IRPC it is each character in one argument For each repetition the argument is substituted for one formal parameter For example PSECT idata_0 IRP number 4865h 6C6Ch 6F00h DW number ENDM PSECT text0 130 Macro Assembler HI TECH C Assembly Language would expand to PSECT idata_0 DW 4865h DW 6C6Ch DW 6F00h PSECT text0 Note that you can use local labels and angle brackets in the same manner as with conventional macros The IRPC directive is similar except it substitutes one character at a time from a string of non space characters For example PSECT romdata class CODE delta 2 IRPC char ABC DB char ENDM PSECT text will expand to PSECT romdata class CODE delta 2 DB A DB B DB C PSECT text 4 3 10 20 PROCESSOR The output of the assembler may vary depending on the target device The device name is typically set using the CHIP option to the command line driver PICC32 see Section 2 6 20 or using the assembler P option see Table 4 1 but can also be set with this directive e g PROCESSOR 16F877 4 3 10 21 SIGNAT This directive is used to associate a 16 bit signature value with a label At link time the linker checks that all signatures defined for a particular label are the same and produces an error if they are not The 131 HI TECH C Assembly Language Macro Assembler Table 4 10 PIC32 assembler controls
384. t is used data read from this hex file will be shifted by the Offset to a new address when generating the output The offset can be either positive or negative For example r100 1FFs2000 myfile hex will shift the block of data from 100h 1FFh to the new address range 2 00h 21FFh Be careful when shifting sections of executable code Program code shouldn t be shifted unless it can be guaranteed that no part of the program relies upon the absolute location of this code segment 5 14 1 2 Prefix When the operator precedes a parameter or input file the data obtained from that parameter will be forced into the output file and will overwrite other data existing within its address range For example input hex STRING 1000 My string Ordinarily hexmate will issue an error if two sources try to store differing data at the same location Using the operator informs hexmate that if more than one data source tries to store data to the same address the one specified with a will take priority 5 14 1 3 ADDRESSING By default all address parameters in hexmate options expect that values will be entered as byte addresses In some device architectures the native addressing format may be something other than byte addressing In these cases it would be much simpler to be able to enter address components in the device s native format To facilitate this the ADDRESSING option is used This option takes exactly one parameter which con
385. t the Intel hex format specification for valid record types 962 forced data conflict at address h between and Hexmate Sources to Hexmate force differing data to be stored to the same address More than one source using the specifier store data at the same address The actual data stored there may not be what you expect 963 checksum range includes voids or unspecified memory locations Hexmate Checksum range had gaps in data content The runtime calculated checksum is likely to differ from the compile time checksum due to gaps unused byes within the address range that the checksum is calculated over Filling unused locations with a known value will correct this 964 unpaired nibble in FILL value will be truncated Hexmate The hexadecimal code given to the FILL option contained an incomplete byte The incomplete byte nibble will be disregarded 393 Error and Warning Messages 965 STRPACK option not yet implemented option will be ignored Hexmate This option currently is not available and will be ignored 966 no END record for HEX file Hexmate Intel hex file did not contain a record of type END The hex file may be incomplete 967 unused function definition from line Parser The indicated static function was never called in the module being compiled Being static the function cannot be called from other modules so this warning implies the function is never used Either the f
386. tdio h gt char x This is a string void main void char cp Cp X while x putchar x putchar An See Also putc getc freopen felose Return Value The character passed as argument or EOF if an error occurred 234 Library Functions Note This routine is not usable in a ROM based system 235 Library Functions PUTS Synopsis include lt stdio h gt int puts const char s Description The puts function writes the string s to the stdout stream appending a newline The null character terminating the string is not copied Example include lt stdio h gt void main void puts Hello world See Also fputs gets freopenQ fcloseQ Return Value EOF is returned on error zero otherwise 236 Library Functions QSORT Synopsis include lt stdlib h gt void qsort void base size_t nel size_t width int func const void const void Description The qsort function is an implementation of the quicksort algorithm It sorts an array of nel items each of length width bytes located contiguously in memory at base The argument func is a pointer to a function used by qsort to compare items It calls fune with pointers to two items to be com pared If the first item is considered to be greater than equal to or less than the second then func should return a value greater than zero equal to zero or less than zero respec
387. te a module name and record number which is less directly associated with any particular line of code Some messages relate to driver options which are in no way associated with any source code There are several ways of changing the format in which message are displayed which are dis cussed below The driver option E with or without a filename alters the format of all displayed messages See Section 2 6 3 Using this option produces messages that are better suited to machine parsing and user friendly Typically each message is displayed on a single line The general form of messages produced with the E option in force is filename line_number message number message string message type The E option also has another effect If it is being used the driver first checks to see if special environment variables have been set If so the format dictated by these variables are used as a template for all messages produced by all compiler applications The names of these variables are given in Table 2 4 The value of these environment variables are strings that are used as templates for the message format Printf like placeholders can be placed within the string to allow the message format to be customised The placeholders and what they represent are indicated in Table 2 5 If these options are used in a DOS batch file two percent characters will need to be used 38 PICC32 Command line Driver Compiler Messages Table 2 4 Messaging env
388. technical support 891 can t open psect usage map file Driver The driver was unable to open the indicated file The psect usage map file is generated by the driver when the driver option summary file is used Ensure that the file is not open in another application 892 can t open memory usage map file Driver The driver was unable to open the indicated file The memory usage map file is generated by the driver when the driver option summary file is used Ensure that the file is not open in another application 893 can t open HEX usage map file Driver The driver was unable to open the indicated file The HEX usage map file is generated by the driver when the driver option summary file is used Ensure that the file is not open in another application 388 Error and Warning Messages 894 unknown source file type Driver The extension of the indicated input file could not be determined Only files with the extensions as c obj usb pl lib or hex are identified by the driver 895 can t request and specify options in the one command Driver The usage of the driver options getoption and setoption is mutually exclusive 896 no memory ranges specified for data space Driver No on chip or external memory ranges have been specified for the data space memory for the device specified 897 no memory ranges specified for program space Driver No on chip or exter
389. ted Under the d key letter the named object files will be deleted from the library In this instance it is an error not to give any object file names The mand s key letters will list the named modules and in the case of the s keyletter the symbols defined or referenced within global symbols only are handled by the librarian As with the r and x key letters an empty list of modules means all the modules in the library The o key takes a list of module names and re orders the matching modules in the library file so they have the same order as that listed on the command line Modules which are not listed are left 156 Linker and Utilities Librarian in their existing order and will appear after the re ordered modules 5 10 3 Examples Here are some examples of usage of the librarian The following lists the global symbols in the modules a obj b obj and c obj LIBR s file lib a obj b obj c obj This command deletes the object modules a obj b obj and c obj from the library file lib LIBR d file lib a obj b obj c obj 5 10 4 Supplying Arguments Since it is often necessary to supply many object file arguments to LIBR and command lines are restricted to 127 characters by CP M and MS DOS LIBR will accept commands from standard input if no command line arguments are given If the standard input is attached to the console LIBR will prompt for input Multiple line input may be given by using a backslash as a continuation character o
390. teger time_zone This should contain the number of minutes that the local time zone is westward of Greenwich On systems where it is not possible to predetermine this value localtime will return the same result as gmtime Example include lt stdio h gt include lt time h gt char wday Sunday Monday Tuesday Wednesday Thursday Friday Saturday hi void main void time_t clock struct tm tp time amp clock tp localtime amp clock printf Today is s n wday tp gt tm_wday 219 Library Functions See Also ctime asctime time Return Value Returns a structure of type tm Note The example will require the user to provide the time routine as one cannot be supplied with the compiler See time for more detail 220 Library Functions LOG LOG10 Synopsis include lt math h gt double log double f double log10 double f Description The log function returns the natural logarithm of f The function log10Q0 returns the logarithm to base 10 of f Example include lt math h gt include lt stdio h gt void main void double f for f 1 0 lt 10 0 1 0 printf log 1 0f f n f log f See Also exp pow Return Value Zero if the argument is negative 221 Library Functions LONGJMP Synopsis include lt setjmp h gt void longjmp jmp_buf buf int val Description
391. ter or define the parameter using pointer syntax e g param should be int array or int int get_first int array 10 warning flagged here return array 0 369 signed bitfields not supported Parser Only unsigned bitfields are supported If a bitfield is declared to be type int the compiler still treats it as unsigned e g struct signed int sign 1 this must be unsigned signed int value 15 bi 370 illegal basic type int assumed Parser The basic type of a cast to a qualified basic type couldn t not be recognised and the basic type was assumed to be int e g 337 Error and Warning Messages here ling is assumed to be int unsigned char bar unsigned ling a 371 missing basic type int assumed Parser This declaration does not include a basic type so int has been assumed This declaration is not illegal but it is preferable to include a basic type to make it clear what is intended e g char c de don t let the compiler make assumptions use int 1 func ditto use extern int func int 372 expected Parser A comma was expected here This could mean you have left out the comma between two identifiers in a declaration list It may also mean that the immediately preceding type name is misspelled and has thus been interpreted as an identifier e g unsigned char a thinks chat amp b are unsigned but where
392. ter may not have storage allocated for it in memory and thus it is illegal to attempt to take the address of it by applying the operator e g int proc register int in int ip amp in oops in may not have an address to take return ip 201 taking the address of this object is illegal Parser The expression which was the operand of the amp operator is not one that denotes memory storage an lvalue and therefore its address can not be defined e g ip amp 8 oops you can t take the address of a literal 304 Error and Warning Messages 202 only Ivalues may be assigned to or modified Parser Only an lvalue i e an identifier or expression directly denoting addressable storage can be assigned to or otherwise modified e g int array 10 int ip char Cc array ip array isn t a variable it can t be written to A typecast does not yield an lvalue e g the contents of c cast to int is only a intermediate value int c 1 However you can write this using pointers int 8c 1 203 illegal operation on bit variable Parser Not all operations on bit variables are supported This operation is one of those e g bit b int ip ip amp b oops cannot take the address of a bit object 204 void function can t return a value Parser A void function cannot return a value Any return statement should not be followed by an expr
393. ters and return values however no other code is necessary If a signature value is present in the assembly code routine its value will be checked by the linker when the calling and called routines signatures can be compared TUTORIAL To continue the previous example here is a code snippet that declares the operation of the assembler routine then calls the routine extern unsigned short add unsigned short a unsigned short b void main void 90 C Language Features Mixing C and Assembly Code short a result a read_port result add 5 a Another example suppose you have an assembly language function to double an unsigned byte value extern __strictcall char twice char declares an external function called twice which has a return value type of char and takes a single argument of type char The actual code for twice will be supplied by an external as file which will be separately assembled with ASPIC32 The full PIC32 assembly code for twice would be something like PROCESSOR 32MX360F512L PSECT text32 class KSEGO_PFM local reloc 4 isa mips32r2 GLOBAL _twice SIGNAT _twice 1049 _twice parameter passed via a0 register if using __strictcall sll a0 1 andi a0 1 lt lt 8 1 move v0 a0 Jr ra END The name of the assembly language function is the name declared in C with an underscore prepended The GLOBAL pseudo op is the assembler equivalent to the C extern keyword and the SIGNAT p
394. the line specified 1025 unknown architecture in chipinfo file at line Driver The attribute at the line indicated defines an architecture that is unknown to this compiler 1026 missing architecture in chipinfo file at line Assembler The chipinfo file has a processor section without an ARCH values The architecture of the processor must be specified Contact HI TECH Support if the chipinfo file has not been modified 1027 activation was successful Driver The compiler was successfully activated 1028 activation was not successful error code Driver The compiler did not activated successfully 1029 compiler not installed correctly error code Driver This compiler has failed to find any activation information and cannot proceed to execute The com piler may have been installed incorrectly or incompletely The error code quoted can help diagnose the reason for this failure You may be asked for this failure code if contacting HI TECH Software for assistance with this problem 1030 HEXMATE Intel hex editing utility Build 1 i Hexmate Indicating the version number of the Hexmate being executed 1031 USAGE input1 hex input2 hex inputN hex options Hexmate The suggested usage of Hexmate 399 Error and Warning Messages 1032 use HELP lt option gt for usage of these command line options Hexmate More detailed information is available for a specific option by
395. the memory space in which the reservation will take place address is the address at which the reservation will take place and bytes is the number of bytes that is to be reserved This directive differs to the DS directive in that it does not allocate space at the curernt location in the current psect but instead can be used to reserve memory at any location The memory space number is the same as the number specified with the space flag option to psects Devices with a single flat memory space will typically always use 0 as the space value devices with separate code and data spaces typically use O for the code space and 1 for the data space The code generator issues a DABS directive for every user defined absolute C variable or for variables that have been allocated an address by the code generator 4 3 10 14 IF ELSIF ELSE and ENDIF These directives implement conditional assembly The argument to IF and ELSIF should be an absolute expression If it is non zero then the code following it up to the next matching ELSE ELSIF or ENDIF will be assembled If the expression is zero then the code up to the next matching ELSE or ENDIF will be skipped At an ELSE the sense of the conditional compilation will be inverted while an ENDIF will termi nate the conditional assembly block Example IF ABC goto aardvark ELSIF DEF 127 HI TECH C Assembly Language Macro Assembler goto denver ELSE goto grapes ENDIF In this example if
396. the name of the file that contains the additional options that will be passed to the application This option is not required for most projects If specifying more than one option to a component each option must be entered on a new line in the option file This option can also be used to remove an application from the build sequence If the file param eter is specified as of f execution of the named application will be skipped In most cases this is not desirable as almost all applications are critical to the success of the build process Disabling a critical application will result in catastrophic failure However it is permissible to skip a non critical application such as clist or hexmate if the final results are not reliant on their function 2 6 52 STRICT Strict ANSI Conformance The STRICT option is used to enable strict ANSI conformance of all special keywords HI TECH C supports various special keywords for example the persistent type qualifier If the STRICT option is used these keywords are changed to include two underscore characters at the beginning of the keyword e g __persistent so as to strictly conform to the ANSI stan dard Be warned that use of this option may cause problems with some standard header files e g lt intrpt h gt 2 6 53 STRICTCALLS Strict MIPS Parameter Passing The STRICTCALLS option is used to enable strict MIPS parameter passing for the entire program HI TECH C PRO for the PIC32 MCU Fa
397. the true statement if a 4 b 6 will produce code that sets a to 5 then immediately sets b to 6 No code will be produced for the comparison if a 4 If a was a global variable it may be that other functions particularly interrupt functions may modify it and so tracking the variable cannot be performed This warning may indicate more than an optimization made by the compiler It may indicate an expression with missing or badly placed parentheses causing the evaluation to yield a value different to what you expected This warning may also be issued because you have written something like while 1 To produce an infinite loop use for A similar situation arises with for loops e g int a b this loop must iterate at least once for a 0 a 10 att b func a In this case the code generator can again pick up that a is assigned the value 0 then immediately checked to see if it is equal to 10 Because a is modified during the for loop the comparison code cannot be removed but the code generator will adjust the code so that the comparison is not performed on the first pass of the loop only on the subsequent passes This may not reduce code size but it will speed program execution 375 Error and Warning Messages 758 constant conditional branch possible use of instead of Code Generator There is an expression inside an if or other conditional construct where a constant is being assig
398. the unsigned char addition of these values without promotion after the unsigned int result was converted back to unsigned char the final result would be the same An 8 bit addition is more efficient than a 16 bit addition and so the compiler will encode the former If in the above example the type of a was unsigned int then integral promotion would have to be performed to comply with the ANSI standard 3 7 2 Shifts applied to integral types The ANSI standard states that the result of right shifting gt gt operator signed integral types is implementation defined when the operand is negative Typically the possible actions that can be taken are that when an object is shifted right by one bit the bit value shifted into the most significant bit of the result can either be zero or a copy of the most significant bit before the shift took place The latter case amounts to a sign extension of the number PICC 32 performs a sign extension of any signed integral type for example signed char signed int or signed long Thus an object with the signed int value 01240000h shifted right one bit will yield the value 00920000h and the value 80240000h shifted right one bit will yield the value CO120000h 84 C Language Features Psects Table 3 5 Integral division Operand 1 Operand 2 Quotient Remainder 5 S a Si Right shifts of unsigned integral values always clear the most signi
399. ther s1 points to string which is less than equal to or greater than the string pointed to by s2 in the collating sequence 226 Library Functions MKTIME Synopsis include lt time h gt time_t mktime struct tm tmptr Description The mktime function converts the local calendar time referenced by the tm structure pointer tmptr into a time being the number of seconds passed since Jan 1 1970 or 1 if the time cannot be represented Example include lt time h gt include lt stdio h gt void main void struct tm birthday birthday tm_year 1955 birthday tm_mon 2 birthday tm_mday 24 birthday tm_hour birthday tm_min birthday tm_sec 0 printf you have been alive approximately ld seconds n mktime amp birthday See Also ctime asctime 227 Library Functions Return Value The time contained in the tm structure represented as the number of seconds since the 1970 Epoch or 1 if this time cannot be represented 228 Library Functions MODF Synopsis include lt math h gt double modf double value double iptr Description The modf function splits the argument value into integral and fractional parts each having the same sign as value For example 3 17 would be split into the integral part 3 and the fractional part 0 17 The integral part is stored as a double in the object pointed to by iptr Example include lt math h gt includ
400. ther source is desired e g a serial port The module getch c in the SOURCES directory contains model versions of all the console I O routines Other modules may also be supplied e g ser180 c has routines for the serial port in a Z180 Example include lt conio h gt void main void char c while c getche n continue See Also cgets cputs ungetch 207 Library Functions GETCHAR Synopsis include lt stdio h gt int getchar void Description The getchar routine is a getc stdin operation It is a macro defined in stdio h Note that under normal circumstances getchar will NOT return unless a carriage return has been typed on the console To get a single character immediately from the console use the function getch Example include lt stdio h gt void main void int while c getchar EOF putchar c See Also getc fgetc freopen fcloseQ Note This routine is not usable in a ROM based system 208 Library Functions GETS Synopsis include lt stdio h gt char gets char s Description The gets function reads a line from standard input into the buffer at s deleting the newline cf fgets The buffer is null terminated In an embedded system gets is equivalent to cgets and results in getche being called repeatedly to get characters Editing with backspace is available Example include lt stdio h gt
401. thus allowing library routines to be easily replaced with user defined alterna tives See Section 3 12 1 The C standard libraries and libraries of implicitly called assembly routines can be omitted from the project by disabling the clib suboption of RUNTIME 2 6 48 For example RUNTIME default clib If these libraries are excluded from the project then calls to any routine or access of any variable that is defined in the omitted library files will result in an error from the linker The user must provide alternative libraries or source files containing definitions for any routine or symbol accessed by the project Do not confuse the actual library 11b files and the header h files Both are covered by a library package but the library files contain precompiled code typically functions and variable definitions the header files provide declarations as opposed to defini tions for functions variables and types in the library files as well as other preprocessor macros PICC32 will always link in all the library files associated with the C standard library unless you have used an option to prevent this however with user defined li brary packages the inclusion of a header does not imply that the corresponding library file s will be searched 27 Runtime Files PICC32 Command line Driver 2 3 1 1 Standard Libraries The C standard libraries contain a standardised collection of functions such as string math and input
402. time Environment 60 2 6 49 SCANDEP Scan for Dependencies o 61 2 6 50 SERIAL hexcode address Store a Value at this Program Memory AQUIESS coo cosmos e A 61 2 6 51 SETOPTION app file Set the Command line Options for Application 62 2 6 52 STRICT Strict ANSI Conformance 0 osos mia ee es 62 2 6 53 STRICTCALLS Strict MIPS Parameter Passing 62 2 6 54 SUMMARY t ype Select Memory Summary Output Type 63 2 6 55 TIME Report time taken for each phase of build process 63 2 6 56 VER Display The Compiler s Version Information 63 2 6 57 WARN level Set Warning Level o 63 2 6 58 WARNFORMAT format Set Warning Message Format 64 CONTENTS CONTENTS 3 C Language Features 65 ul ANSI Standard Issues soote aa a A a a Ae a a a 65 3 1 1 Divergence from the ANSIC Standard oo o 65 3 1 2 Implementation defined behaviour 65 313 Non ANSI Operations seo pc bebe eee we SSE e EAD ERS ES 65 3 2 Processorrelated Features 2 ee a we eS 66 3 2 1 Processor Support cocer a id me Re LE 66 S22 Configuration Fuses ss es eeu dea r ee ea ee a 66 32a Multisbyte SFRS cu co a o a a R RRA a ea 67 3 3 Supported Data Types and Variables ociosa e 67 3 3 1 Radix Specifiers and Constants lt o cs sa yere ape 64 A 67 33 2 Bit Data Types and Variables s sic c bt ee oea ae a Sea
403. tion of this manual that describes this option to see what tags 1f any are valid for this device 908 exit status Driver One of the subcomponents being executed encountered a problem and returned an error code Other messages should have been reported by the subcomponent to explain the problem that was encoun tered 913 option may cause compiler errors in some standard header files Driver Using this option will invalidate some of the qualifiers used in the standard header files resulting in errors This issue and its solution are detailed in the section of this manual that specifically discusses this option 915 no room for arguments Preprocessor Parser Code Generator Linker Objtohex The code generator could not allocate any more memory 917 argument too long Preprocessor Parser This is an internal compiler error Contact HI TECH Software technical support with details 918 no match Preprocessor Parser This is an internal compiler error Contact HI TECH Software technical support with details 919 in chipinfo file at line Driver The specified parameter in the chip configuration file is illegal 920 empty chipinfo file Driver Assembler The chip configuration file was able to be opened but it was empty Try re installing the compiler 390 Error and Warning Messages 922 chip not present in chipinfo file Driver The chip selected does not appear in the c
404. tions such as the code generator assembler and linker 41 PICC32 Driver Option Descriptions PICC32 Command line Driver PICC32 recognizes the compiler options listed in the table below The case of the options is not important however command shells in UNIX based operating systems are case sensitive when it comes to names of files All single letter options are identified by a leading dash character e g C Some single letter options specify an additional data field which follows the option name immediately and without any whitespace e g Ddebug Multi letter or word options have two leading dash characters e g ASMLIST Because of the double dash you can determine that the option ASMLIST for example is not a A option followed by the argument SMLIST Some of these options define suboptions which typically appear as a comma separated list following an equal character e g OUTPUT hex cof The exact format of the options varies and are described in detail in the following sections Some commonly used suboptions include default which represent the default specification that would be used if this option was absent altogether all which indicates that all the available suboptions should be enabled as if they had each been listed and none which indicates that all suboptions should be disabled Some suboptions may be prefixed with a plus character to indicate that they are in addition to the other suboptions pr
405. tions are restricted to registers 1 27 mips16e functions are restricted to registers 4 7 Any arguments larger than 4 bytes will always be passed on the stack in reverse order If the STRICTCALLS option 2 6 53 or strictcal1 qualifier 3 3 10 4 is used only the first 4 A registers are used for passing parameters If the strictcalls option and or qualifier is not used the HI TECH C PRO for the PIC32 MCU Family will dynamically determine which registers to use for passing parameters 3 5 3 Function Return Values Function return values are passed to the calling function as follows Function return values of a type equal to or less than 4 bytes are returned via register 2 v0 Return values of a type greater than 4 bytes are passed on the stack In these cases the function will reuse as much of the current stack frame as possible to pass the value 81 Register Usage Conventions C Language Features High Address Allocated by Caller Stack Growth Allocated by Callee Low Address a stackframe Figure 3 1 General Function Stack Frame 3 5 4 Function Stack Frame Figure 3 1 illustrates the general arrangement of function stack frames used by the compiler 3 6 Register Usage Conventions Some of the general purpose registers of the device have been dedicated depending on context to certain roles All functions both mips32r2 and mips16e with a return type equal to or less than 4 bytes will return their value in regi
406. tively Example include lt stdio h gt include lt stdlib h gt int aray 567 23 456 1024 17 567 66 hi int sortem const void pl const void p2 return int pl int p2 void main void register int i 237 Library Functions qsort aray sizeof aray sizeof aray 0 sizeof aray 0 sortem for i 0 i sizeof aray sizeof aray 0 i printf Sd t aray 1 putchar An Note The function parameter must be a pointer to a function of type similar to int func const void const void 1 e 1t must accept two const void parameters and must be prototyped 238 Library Functions RAND Synopsis include lt stdlib h gt int rand void Description The rand function is a pseudo random number generator It returns an integer in the range 0 to 32767 which changes in a pseudo random fashion on each call The algorithm will produce a deterministic sequence if started from the same point The starting point is set using the srand call The example shows use of the time function to generate a different starting point for the sequence each time Example include lt stdlib h gt include lt stdio h gt include lt time h gt void main void time_t toc int i time amp toc srand int toc for i 0 i 10 itt printf Sd t rand putchar n See Also srand 239 Library Functions Note The e
407. to by s2 Example include lt stdio h gt include lt string h gt void main void printf Sd n strspn This is a string This printf Sd n strspn This is a string this See Also strespn Return Value The length of the segment 266 Library Functions STRSTR STRISTR Synopsis include lt string h gt char strstr const char sl const char s2 char stristr const char sl const char s2 Description The strstr function locates the first occurrence of the sequence of characters in the string pointed to by s2 in the string pointed to by s1 The stristr routine is the case insensitive version of this function Example include lt stdio h gt include lt string h gt void main void printf Sd n strstr This is a string str Return Value Pointer to the located string or a null pointer if the string was not found 267 Library Functions STRTOD Synopsis include lt stdlib h gt double strtok const char s const char res Description Parse the string s converting it to a double floating point type This function converts the first occurence of a substring of the input that is made up of characters of the expected form after skipping leading white space characters If res is not NULL it will be made to point to the first character after the converted sub string Example include lt stdio h gt include lt strlib h
408. trols 132 directives 121 options 110 pseudo ops 121 assembler control COND 133 EXPAND 133 INCLUDE 133 LIST 134 NOCOND 134 NOEXPAND 134 NOLIST 134 NOXREF 134 PAGE 135 SPACE 135 SUBTITLE 135 TITLE 135 XREF 135 422 assembler directive ALIGN 130 DABS 127 DB 126 DS 127 DW 126 ELSE 127 ELSIF 127 END 33 121 ENDIF 127 ENDM 128 EQU 114 125 FNSIZE 91 GLOBAL 91 118 121 IF 127 IRP 130 IRPC 130 LOCAL 118 129 MACRO 114 128 ORG 124 PROCESSOR 91 112 131 PSECT 91 120 121 REPT 130 SET 114 126 SIGNAT 105 131 assembler files preprocessing 57 assembler listings 49 assembler optimizer debug information and 112 enabling 112 viewing output of 111 assembler option A 111 C 111 Cchipinfo 111 E 111 Flength 111 H 111 INDEX INDEX I 111 special characters 114 Llistfile 112 special comment strings 116 O 112 statement format 114 Ooutfile 112 strings 117 Twidth 112 volatile locations 116 V 112 assembly labels 89 114 118 X 112 character 117 processor 112 assembler generated symbols 118 assembly 109 accessing C variables from 93 C prototypes for 89 called from C code 89 character constants 117 character set 114 comments 114 conditional 127 constants 116 default radix 116 delimiters 114 embedding in C code 88 expressions 118 generating from C 48 identifiers 117
409. ts Parser A function declaration can only have all prototyped arguments i e with types inside the parentheses or all K amp R style args i e only names inside the parentheses and the argument types in a declaration list before the start of the function body e g int plus int a b oops a is prototyped b is not int b return a b 278 argument redeclared Parser The specified argument is declared more than once in the same argument list e g can t have two parameters called a int calc int a int a 319 Error and Warning Messages 279 initialization of function arguments is illegal Parser A function argument can t have an initialiser in a declaration The initialisation of the argument happens when the function is called and a value is provided for the argument by the calling function e g oops a is initialized when proc is called extern int proc int a 9 280 arrays of functions are illegal Parser You can t define an array of functions You can however define an array of pointers to functions e g int farray oops should be int farray 281 functions can t return functions Parser A function cannot return a function It can return a function pointer A function returning a pointer to a function could be declared like this int name Note the many parentheses that are necessary to make the parts of the declaration
410. ts may be omitted by disabling the init suboption of RUNTIME For example RUNTIME default init 29 Runtime Files PICC32 Command line Driver With this part of the runtime startup code absent the contents of initialized variables will be unpre dictable when the program begins execution Code relying on variables containing their initial value will fail Since auto objects are dynamically created they require code to be positioned in the function in which they are defined to perform their initialization It is also possible that their initial value changes on each instance of the function As a result initialized auto objects do not use the data psects and are not considered by the runtime startup code Variables whose contents should be preserved over a reset or even power off should be qualified with persistent see Section 3 3 10 1 Such variables are linked at a different area of memory and are not altered by the runtime startup code in any way 2 3 2 2 Clearing the Bss Psect The ANSI standard dictates that those non auto objects which are not initialized must be cleared before execution of the program begins The compiler does this by grouping all such uninitialized objects into one of the bss psects This psect is then cleared as a block by the runtime startup code The abbreviation bss stands for Block Started by Symbol and was an assembler pseudo op used in IBM systems back in the days when computers were coal fire
411. unction is redundant or the code that was meant to call it was excluded from compilation or misspelt the name of the function 968 unterminated string Assembler Optimiser A string constant appears not to have a closing quote missing 969 end of string in format specifier Parser The format specifier for the printf style function is malformed 970 character not valid at this point in format specifier Parser The printf style format specifier has an illegal character 971 type modifiers not valid with this format Parser Type modifiers may not be used with this format 972 only modifiers h and I valid with this format Parser Only modifiers h short and 1 long are legal with this printf format specifier 973 only modifier 1 valid with this format Parser The only modifier that is legal with this format is 1 for long 974 type modifier already specified Parser This type modifier has already be specified in this type 394 Error and Warning Messages 975 invalid format specifier or type modifier Parser The format specifier or modifier in the printf style string is illegal for this particular format 976 field width not valid at this point Parser A field width may not appear at this point in a printf type format specifier 978 this identifier is already an enum tag Parser This identifier following a struct or union keyword is already the tag for an enumerated typ
412. used to specify memory in addition to any RAM specified in the chipinfo file which should be treated as available RAM space Strictly speaking this option specifies the areas of mem ory that may be used by writable RAM based objects and not necessarily those areas of memory which contain physical RAM The output that will be placed in the ranges specified by this option are typically variables that a program defines Some chips have an area of RAM that can be remapped in terms of its location in the memory space This along with any fixed RAM memory defined in the chipinfo file are grouped an made available for RAM based objects For example to specify an additional range of memory to that present on chip use RAM default 100 1ff for example To only use an external range and ignore any on chip memory use RAM 0 ff This option may also be used to reserve memory ranges already defined as on chip memory in the chipinfo file To do this supply a range prefixed with a minus character for example RAM default 100 103 will use all the defined on chip memory but not use the addresses in the range from 100h to 103h for allocation of RAM objects 2 6 47 ROM lo hi lt lo hi gt tag Specify Additional ROM Ranges This option is used to specify memory in addition to any ROM specified in the chip configuration file which should be treated as available ROM space Strictly speaking this option specifies the areas of me
413. utput is a single absolute object file 1 obj This is then passed to the appropriate post link utility applications to generate the specified output file format and debugging files All temporary files including 1 obj are then deleted The inter mediate files p code and relocatable object files are not deleted This tutorial does not consider the runtime startup code that is automatically generated by the driver 2 2 2 Generating Intermediate Files The HI TECH C PRO for the PIC32 MCU Family version compiler uses two types of intermediate files For C source files the p code file p1 file is used as the intermediate file For assembler source files the relocatable object file obj file is used You may wish to generate intermediate files for several reasons but the most likely will be if you are using an IDE or make system that allows an incremental build of the project The advantage of a incremental build is that only the source files that have been modified since the last build need to be recompiled before again running the final link step This dependency checking may result in reduced compilation times particularly if there are a large number of source files You may also wish to generate intermediate files to construct your own library files although PICC32 is capable of constructing libraries in a single step so this is typically not necessary See Section 2 6 42 for more information Intermediate files may also assist with debu
414. value redefined Linker The selector value for this psect has been defined more than once 487 psect type redefined Linker This psect has had its type defined differently by different modules This probably means you are trying to link incompatible object modules e g linking 386 flat model code with 8086 real mode code 488 psect memory space redefined Linker A global psect has been defined in two different memory spaces Either rename one of the psects or if they are the same psect place them in the same memory space using the space psect flag e g psect spdata class RAM space 0 ds 6 elsewhere psect spdata class RAM space 1 489 psect memory delta redefined Linker A global psect has been defined with two different delta values e g psect final class CODE delta 2 finish elsewhere psect final class CODE delta 1 490 class memory space redefined Linker A class has been defined in two different memory spaces Either rename one of the classes or if they are the same class place them in the same memory space 354 Error and Warning Messages 491 can t find 0x words for psect in segment Linker One of the main tasks the linker performs is positioning the blocks or psects of code and data that is generated from the program into the memory available for the target device This error indicates that the linker was unable to f
415. variables used the programmer has little control over their operation This applies whether the compiled code uses a hardware or compiled stack For example after receiving the message 355 Error and Warning Messages Can t find 0x34 words 0x34 withtotal for psect text in segment CODE error look in the map file for the ranges of unused memory UNUSED ADDRESS RANGES CODE 00000244 0000025F 00001000 0000102f RAM 00300014 00301FFB In the CODE segment there is Ox 1c Ox25f 0x244 1 bytes of space available in one block and 0x30 available in another block Neither of these are large enough to accommodate the psect text which is 0x34 bytes long Notice however that the total amount of memory available is larger than 0x34 bytes 492 attempt to position absolute psect is illegal Linker This psect is absolute and should not have an address specified in a P option Either remove the abs psect flag or remove the P linker option 493 origin of psect is defined more than once Linker The origin of this psect is defined more than once There is most likely more than one p linker option specifying this psect 494 bad P format Linker The P option given to the linker is malformed This option specifies placement of a psect e g Ptext 10g0h Maybe you meant Ptext 10f0h 495 use of both with and INCLASS INCLASS allocation is illegal Linker It is not legal to specify both the li
416. void Only a function can be void e g int a void b this makes no sense 289 only functions may be qualified interrupt Parser The qualifier interrupt may not be applied to anything except a function e g variables cannot be qualified interrupt interrupt int input 290 illegal function qualifier s Parser A qualifier has been applied to a function which makes no sense in this context Some qualifier only make sense when used with an lvalue e g const or volatile This may indicate that you have forgotten out a star indicating that the function should return a pointer to a qualified object e g 321 Error and Warning Messages const char ccrv void const char ccrv void perhaps error flagged here return ccip 291 K amp R identifier not an argument Parser This identifier that has appeared in a K amp R style argument declarator is not listed inside the paren theses after the function name e g int process input int unput oops that should be int input 292 function parameter may not be a function Parser A function parameter may not be a function It may be a pointer to a function so perhaps a has been omitted from the declaration 293 bad size in index_type Parser This is an internal compiler error Contact HI TECH Software technical support with details 294 can t allocate bytes of memory Code Generator Hexmate This is an
417. which is a C statement and will correctly interact with all C flow of control structures The following example shows both methods used to shift a byte right by bit unsigned char var void main void var 1 tasm like this lbu a2 x gptr gp sra a2 a2 1 andi a3 a2 255 sb a3 _x __gptr gp endasm asm lbu a2 x gptr gp asm sra a2 a2 1 asm andi a3 a2 255 asm sb a3 _x __gptr gp When using in line assembly code great care must be taken to avoid interacting with compiler generated code If in doubt compile your program with the PICC32 S option and examine the assembly code generated by the compiler IMPORTANT NOTE the asm and endasm construct is not syntactically part of the C program and thus it does not obey normal C flow of control rules For example you cannot use a asm block with an if statement and expect it to work correctly If you use in line assembler around any C 92 C Language Features Mixing C and Assembly Code constructs such as if while do etc then you should use only the asm form which is a C statement and will correctly interact with all C flow of control structures 3 10 3 Accessing C objects from within Assembly Code Global C objects may be directly accessed from within assembly code using their name prepended with an underscore character For example the object foo defined globally in a C module int foo may be access from assembler as
418. which is based on the reloc flag value given to psects at the assembler level This is appropriate for 8086 real mode code but not for protected mode 142 Linker and Utilities Operation or some bank switched arrangements In this instance the G option is used to specify a method for calculating the segment selector The argument to G is a string similar to A 10h 4h where A represents the load address of the segment and represents division This means Take the load address of the psect divide by 10 hex then subtract 4 This form can be modified by substi tuting N for A for to represent multiplication and adding rather than subtracting a constant The token N is replaced by the ordinal number of the segment which is allocated by the linker For example N 8 4 means take the segment number multiply by 8 then add 4 The result is the segment selector This particular example would allocate segment selectors in the sequence 4 12 20 for the number of segments defined This would be appropriate when compiling for 80286 protected mode where these selectors would represent LDT entries 5 7 10 Hsymfile This option will instruct the linker to generate a symbol file The optional argument symfile specifies a file to receive the symbol file The default file name is 1 sym 5 7 11 H symfile This option will instruct the linker to generate an enhanced symbol file which provides in addition to the standard sym
419. xample will require the user to provide the time routine as one cannot be supplied with the compiler See time for more detail 240 Library Functions ROUND Synopsis include lt math h gt double round double x Description The round function round the argument to the nearest integer value but in floating point format Values midway between integer values are rounded up Example include lt math h gt void main void double input rounded input 1234 5678 rounded round input See Also trunc 241 Library Functions SCANF VSCANF Synopsis include lt stdio h gt int scanf const char fmt tinclude lt stdio h gt tinclude lt stdarg h gt int vscanf const char va_list ap Description The scanf function performs formatted input de editing from the stdin stream Similar func tions are available for streams in general and for strings The function vscanf is similar but takes a pointer to an argument list rather than a series of additional arguments This pointer should have been initialised with va_start The input conversions are performed according to the fmt string in general a character in the format string must match a character in the input however a space character in the format string will match zero or more white space characters in the input i e spaces tabs or newlines A conversion specification takes the form of the character option
420. y Module The next section in the map file lists those modules that made a contribution to the output and information regarding the psects these modules defined This section is heralded by the line that contains the headings Name Link Load Length Selector Space Scale Under this on the far left is a list of object files These object files include both files generated from source modules and those that were extracted from object library files In the case of those from library files the name of the library file is printed before the object file list This section shows all the psects under the Name column that were linked into the program from each object file and information regarding that psect This only deals with object files linked by the linker P code modules derived from p code library files are handled by the code generator and do not appear in the map file The Link address indicates the address at which this psect will be located when the program is running The Load address is also shown for those psects that may reside in the HEX file at a different location and which are mapped before program execution The Length of the psect is shown in units suitable for that psect The Selector is less commonly used but the Space field is important as it indicates the memory space in which the psect was placed For Harvard architecture machines with separate memory spaces this field must be used in conjunction with the address to speci
421. y of an interrupt at compile time assign it the appropriate absolute address with the operator These addresses aren t necessarily absolute but are more truly a magic number interpreted by the compiler as referring to a specific interrupt or exception These addresses are defined in the compiler header file lt pic32 h gt See 2 6 31 for more details on the interrupt vector table types and assigning specific interrupt function duties Interrupt functions qualified fast assume that the function will be using a shadow set of general purpose registers reserved for high priority interrupts As a result these functions only perform a minimum of context handling 3 9 2 Interrupt amp Exception Types PICC32 supports the use of several different types of interrupts Briefly these are Non Maskable Interrupts An interrupt function may be assigned the duty of servicing non maskable interrupts by addressing it with the macro NM_INTERRUPT defined in lt pic32 h gt Only one interrupt function may be assigned this duty and only at compile time If no interrupt function is assigned this duty the compiler will generate a default handler which consists solely of an eret instruction General Exceptions An interrupt function may be assigned the duty of servicing general excep tions i e exception 0x180 by addressing it with the macro GENERAL_EXCEPTION in defined 87 Mixing C and Assembly Code C Language Features lt pic32 h gt Only one i
422. y source files debug Favor accurate debugging over optimization all Enable all compiler optimizations none Do not use any compiler optimziations If this option is omitted intermediate files will be created in the current working directory This option will not set the location of output files instead use OUTDIR See 2 6 41 and 2 6 10 for more information 2 6 40 OPT lt type gt Invoke Compiler Optimizations The OPT option allows control of all the compiler optimizers By default without this option all optimizations are enabled The options OPT or OPT a11 also enable all optimizations Opti mizations may be disabled by using OPT none or individual optimizers may be controlled e g OPT asm will only enable some assembler optimizations Table 2 11 lists the available optimiza tion types The optimizations that are controlled through specifying a level 1 through 9 affect opti mization during the code generation stage The level selected is commonly referred to as the global optimization level 2 6 41 OUTDIR path Specify a directory for Output files This option allows a directory to be nominated in for PICC32 to locate its output files If this option is omitted output files will be created in the current working directory This option will not set the location of intermediate files instead use OBJDIR See 2 6 39 and 2 6 10 for more information 2 6 42 OUTPUT type Specify Output File Type This option
423. y this option If the message list is specified as 0 then all warnings are disabled 2 6 36 MSGFORMAT format Set Advisory Message Format This option sets the format of advisory messages produced by the compiler See Section 2 5 for full information 2 6 37 NODEL Do not remove temporary files Specifying NODEL when building will instruct PICC32 not to remove the intermediate and tempo rary files that were created during the build process 2 6 38 NOEXEC Don t Execute Compiler The NOEXEC option causes the compiler to go through all the compilation steps but without ac tually performing any compilation or producing any output This may be useful when used in con junction with the V verbose option in order to see all of the command lines the compiler uses to drive the compiler applications 2 6 39 OBJDIR path Specify a directory for Object files This option allows a directory to be nominated in for PICC32 to locate its intermediate files In termediate file include pre and p1 file for C source and also includes obj and 1st files for assembly source and the compiler generated runtime startup source file 55 PICC32 Driver Option Descriptions PICC32 Command line Driver Table 2 11 Optimization Options Option name Funcion leag Select global optimization level 1 through 9 asm Select optimizations of assembly derived from C source asmfile Select optimizations of assembl
424. yte will result in an error but masking with OOFFh 2 bytes will be Ok 1202 unknown format requested in FORMAT Hexmate An unknown or unsupported INHX format has been requested Refer to documentation for supported INHX formats 1203 unpaired nibble in value will be truncated Hexmate Data to this option was not entered as whole bytes Perhaps the data was incomplete or a leading zero was omitted For example the value Fh contains only four bits of significant data and is not a whole byte The value OFh contains eight bits of significant data and is a whole byte 406 Error and Warning Messages 1204 value must be between 1 and bytes long Hexmate An illegal length of data was given to this option The value provided to this option exceeds the maximum or minimum bounds required by this option 1205 using the configuration file you may override this with the environment variable HTC_XML Driver This is the compiler configuration file selected during compiler setup This can be changed via the HTC_XML environment variable This file is used to determine where the compiler has been installed 1207 some of the command line options you are using are now obsolete Driver Some of the command line options passed to the driver have now been discontinued in this version of the compiler however during a grace period these old options will still be processed by the driver 1208 use help option or refer to

Download Pdf Manuals

image

Related Search

Related Contents

User Manual FPM  Betriebsanleitung Regelung Siemens  JVC LYT0190-001B User's Manual  PALOMA - RV Distribution  Samsung 2333HD Manuel de l'utilisateur  KTI Networks Switch 10/100/1000 Base-T  LMI-1 - 光商工株式会社  Eglo HANIA  Be sure to read and go over all pages before you start your installation    

Copyright © All rights reserved.
Failed to retrieve file