Sunteți pe pagina 1din 10

Changes since the last manual: The EXTERN qualifier is now implemented as it is documented in the ANSI specification.

In general a declaration like this: extern int16 mylong; Will not allocate any memory for mylong. Instead the compiler at link time will search for a declaration somewhere like this: int16 mylong; and it is that declaration that will allocate the storage for both uses. A directive has been added for those who do not want the 0 before a decimal point on %f numbers less than 1. For example: #device %f=. Will print one half as: .5 Without the directive it prints as: 0.5 The PCW IDE will accept user defined keywords for color syntax highlighing if there is a file named TOKENS.TXT in the PICC directory with one keyword per line. PIC18 interrupts now allow the HIGH option to mark an interrupt as high priority . A summary of the different kinds of PIC18 interupts: #INT_xxxx Normal (low priority) interrupt. Compiler saves/restores key registe rs. This interrupt will not interrupt any interrupt in progress. #INT_xxxx FAST High priority interrupt. Compiler DOES NOT save/restore key register s. This interrupt will interrupt any normal interrupt in progress. Only one is allowed in a program. #INT_xxxx HIGH High priority interrupt. Compiler saves/restores key registers. This interrupt will interrupt any normal interrupt in progress. #INT_GLOBAL Compiler generates no interrupt code. User function is located at address 8 for user interrupt handling. A new function _MUL has been added. This function accepts either two 8 bit arguments yielding a 16 bit result or two 16 bit arguments yielding a 32 bit result. This function provides an advantage over the standard C * operator for these operations since a conversion to the higher order type is not done on the operands. This makes the multiply faster. Example: int8 a,b; int16 c; c = _mul(a,b); The printf has been enhanced as folliows: %f is now more optimzed and the rounding problems are fixed. The max width is now 9 for %f. %g has been added. It is the same as %f except the value is rounded. %w has been added. The width and precision are specified just as %f however the value is an integer. An imaginary decimal point is inserted at the requested position. For example int32 value; value = 12345; printf( "%6.2w", value); // prints 123.45

A new function I2C_ISR_STATE() has been added to help determine what to do in an I2C slave interrupt function. See the updated EX_SLAVE.C for an example. The PCW IDE now allows user defined tokens to be added for color syntax highligh ting by putting them in a file names TOKENS.TXT in the PICC directory. The LCD_SYMBOL function now allows 2-17 parametters. The first may be an int8 or int16. Each remaining parametter represents one segment of the symbol. This allows for symbols with 1-16 segments. #ERROR has been updated to allow for warning and information messages: #error/warning this is a warning message #error/information this is an information message A new function has been added to jump from the real PIC interrupt vector to a relocated vector. This is usefull for bootloaders. See bootloader.c for an example. JUMP_TO_ISR(relocated_address); The I2C_START function will now accept an optional parametter. If 1 the compiler assumes the bus is in the stopp'ed state. If 2 the compiler treats this I2C_START as a restart. If no parametter is passed a 2 is used only if the compiler compiled a I2C_START last with no I2C_STOP since. A new #TYPE option has been added to allow the default address space for a block of code to be specified. For example to allocate a block of variables to the memory area 0x100 to 0x1FF do this: typemod <,,,0x100,0x1ff> user_ram_block; #type default=user_ram_block ... all variable declarations in this area ... will be in 0x100-0x1FF #type default= ... memory allocation back to normal A capability for using encrypted include files has been added to the compiler. To create an encrypted include file use the PCW FILE menu and select ENCRYPT. A file with the extension ".encrypted" will be created. The standard compiler #include directive will accept files with this extension and decrypt them as they are read. This allows include files to be distributed without releasing the source code. A new function setup_low_volt_detect() has been added for chips with this feature. To trigger when the voltage is below 3.6 volts for example use: setup_low_volt_detect( LVD_TRIGGER_BELOW | LVD_36 ); A change has been made to the way FAST interrupts (high priority interrupts) are used. Before you can use the keyword FAST you must add the following line after you include the device .h file: #device HIGH_INTS=TRUE There will be more features added for FAST interrupts soon.

The #build directive now has an option to eliminate the SLEEP put at the end of main(): #build(NOSLEEP) Clarification about the functions to write to program memory: For chips where getenv("FLASH_ERASE_SIZE") > getenv("FLASH_WRITE_SIZE") WRITE_PROGRAM_EEPROM - Writes 2 bytes, does not erase (use ERASE_PROGRAM_EEPROM) WRITE_PROGRAM_MEMORY - Writes any number of bytes, will erase a block whenever the first (lowest) byte in a block is written to. If the first address is not the start of a block that block is not erased. ERASE_PROGRAM_EEPROM - Will erase a block. The lowest address bits are no t used. For chips where getenv("FLASH_ERASE_SIZE") = getenv("FLASH_WRITE_SIZE") WRITE_PROGRAM_EEPROM - Writes 2 bytes, no erase is needed. WRITE_PROGRAM_MEMORY - Writes any number of bytes, bytes outside the range of the write block are not changed. No erase is ne eded. ERASE_PROGRAM_EEPROM - Not available. For chips that allow writes to the configuration fuses: WRITE_CONFIGURATION_MEMORY(ramaddress, count) - Writes count bytes, no era se needed or WRITE_CONFIGURATION_MEMORY(offset,ramaddress, count) - Writes count bytes, no erase needed starting at byte ad dress offset The #USE I2C now allows the speed to be adjusted. For example: #USE I2C(MASTER, SCL=PIN_B0, SDA=PIN_B1, FAST=450000 ) Sets the target speed to 450 KBSP. SETUP_UART now accepts the following new options for chips with the EUART H/W: UART_AUTODETECT - Waits for a 0x55 character and sets the UART baud rate to match UART_AUTODETECT_NOWAIT - As above however the function returns before 0x55 is rcvd. KBHIT() will be true when the match is made. A call to GETC() will clear the character. UART_WAKEUP_ON_RDA - The UART will wake the PIC up out of sleep when RCV goes from high to low. A new I/O function has been added: value = INPUT_STATE(pin_xx); This functions reads the I/O pin state without changing the direction of the pin as INPUT() does. The compiler operation concerning type conversions to an int1 have changed to be ANSI compliant. Old way: onebit = eightbits; // Same as: onebit = (eightbits != 0) New way: onebit = eightbits; // Same as: onebit = (eightbits & 1)

Relational expresions (in IF and WHILE and around && and ||) are not affected by this change.

Functions get_timer1, set_timer5 and setup_timer_5 have been added. They work like the timer 1 functions. PIC18 parts with external ROM can direct the compiler to use the ROM like this: #build(memory=0x20000:0x2FFFF) For chips with no internal ROM you must use a line like the above. The reset and interrupt vectors can be moved from the normal location using #build like this: #build(reset=0x200, interrupt=0x208) A larger than normal area may be reserved like this: #build(reset=0x200:0x207, interrupt=0x208:0x2ff) The ADC functions have been updated to support the newest chips. Many of the constants used for the functions have changed however for a couple of months the old constants will be included in the .h files. See your devices .h file for details. New PIC18 optimization has been added. To use the new optimization add: #opt 10 or #opt 11 A new directive has been added to specify the data to be used to fill unused ROM locations. For example: #fill_rom 0x0063 New directive to prevent WRITE_EEPROM from hanging while the write takes place: #device WRITE_EEPROM=ASYNC If you use this do not write to the EERPOM from both an ISR and outside an ISR. A new function CLEAR_INTERRUPT has been added. For example: clear_interrupt( INT_EXT ); The #ROM directive now creates a segment for the #ROM data. This means you will get an error if you #ORG over the same area. This was not previously an error. It also means #ROM data is counted as used program memory space. These changes only apply if the #ROM address is inside the program memory space. A new function has been added: SETUP_UART that works the same as SET_UART_SPEED . A new feature of this function is when a FALSE (or 0) is passed it turns off the UART and when a TRUE (or 1) is passed in it turns the UART on. Passing in a baud rat e also turns on the UART. The following constants may also be used on chips with the a dvanced UART: UART_ADDRESS - UART only accepts data with 9th bit =1 UART_DATA - UART accepts all data

New options for #USE RS232: SAMPLE_EARLY A getc() normally samples data in the middle of a bit time. Thi s option causes the sample to be at the start of a bit time. May not be used with t he UART. RETURN=pin For FLOAT_HIGH and MULTI_MASTER this is the pin used to read the signal back. The default for FLOAT_HIGH is the XMIT pin and for MULTI_MASTER the RCV pin. MULTI_MASTER Uses the RETURN pin to determine if another master on the bus is transmitting at the same time. If a collision is detected bit 6 is set in RS232 _ERRORS and all future PUTC's are ignored until bit 6 is cleared. The signal is checked at the start and end of a bit time. May not be used with the UART. LONG_DATA Makes getc() return an int16 and putc accept an int16. This is for 9 bit data formats. DISABLE_INTS Will cause interrupts to be disabled when the routines get or pu t a character. This prevents character distortion for software implemented I/O and prevents interaction between I/O in interrupt handlers and the main program when usin g the UART. See RS485.C in the drivers directory for an example RS485 protocol implementa tion. A new function SETUP_OSCILLATOR controls and returns the state of the internal RC oscillator on some parts. See the devices .h file for valid options for a particular device. Note that is INTRC or INTRC_IO is specified in #fuses and a #USE DELAY is used for a valid speed option, then the compiler will do this setup automatically at the start of main(). WARNING: If the speed is changed at run time the compiler may not generate the correct delays for some built in functions. The last #USE DELAY encountered in the file is always assumed to be the correct speed. You can have multiple #USE DELAY lines to control the compilers knowledge about the speed. To instruct the compiler to use the extermal program memory in a part add the following line after the devices .h file is included: #BUILD( memory=start:end ) Where start and end represent the external address space. A new built in function OUTPUT_TOGGLE(pin) will toggle the state of a specified pin. The parameter is the same as OUTPUT_HIGH. A new preprocessor directive has been added to make serial numbers easier to implement. This new feature only works with the CCS ICD units. It is implemented by inserting comments in the hex file that the ICD.EXE program understands. #serialize(id=xxx, file="filename.txt", listfile="filename.txt", prompt="text", log="filename.txt", next="xxx") id=xxx r array Specify a C CONST identifier, may be int8,int16,int32 or cha

file="x" this his is

Use only one of the next three options: The file x is used to read the serial number from, and file is updated by the ICD programmer. It is asumed t a one line file with the serial number. The programme

r will listfile="x" this file is updated by the ICD programmer. It is asumed t his is a file one serial number per line. The programmer wil l read the next="x" he hex file is updated to increment x by one. prompt="text" This option is optional. If specified the user will b e prompted for a serial number on each load. If used with one of the above three options then the default value the user may use is picked according to the above rules. log="xxx" date, time, programmed. If no id=xxx is specified then this may be used as a s imple log of all loads of the hex file. #USE I2C now accepts an SMBUS option. The CCSC program will now accept a +DF command line option to enable the output of a COFF debug file. MPLAB 6 may work better with this new file format. The MPLAB plug-in will be updated to make this the default. A new capability has been added to define a memory region. For example: typemod <,,,0x110,0x16f> banktwo; Will define a memory space named banktwo. The first three options for the typemod are for future expansion. The new type specifier may be used like this: char banktwo buffer[20]; The read_adc() function has an optional parameter to control what read_adc does. The default is ADC_START_AND_READ however you may also specify ADC_START_ONLY to start a conversion (read_adc() returns nothing) and ADC_READ_ONLY to read the last result. For example: read_adc(ADC_START_ONLY); sleep(); value=read_adc(ADC_READ_ONLY); New capabilities for the 629,630,675,676 chips: The PORT_B_PULLUPS function accepts a number like SET_TRIS_B to enable specific pins. For some chips this function is named PORT_A_PULLUPS. A file may optionaly be specified to keep a log of the hex file name and serial number each time the part is first line then delete that line from the file. The serial number X is used for the first load, then t increment the serial number. The file x is used to read the serial number from, and

enable/disable_interrupt() functions have constants (see .h file) defned to enable/disable change on specific pins. For example: enable_interrupts(INT_RA1); A new error file format is now available. This new format is invoked with the following command line options: +EW Show warning messages +EA Show all error messages and all warnings +EA -EW Show all error messages and no warnings This is invoked in PCW from OPTIONS > FILE FORMATS. This is not yet available in MPLAB 6. CCS has not yet removed warning conditions from the example programs and include files. A new pre-processor directive may be used to surpress certain warnings: #IGNORE_WARNINGS ALL #IGNORE_WARNINGS NONE #IGNORE_WARNINGS 201 #IGNORE_WARNINGS 201,205,212 A new function has been added to make program memory writes more effective for the variety parts now available: WRITE_PROGRAM_MEMORY( address, dataptr, count ); address is a byte address in PIC18 and PIC16, the LSB should be 0 dataptr points to the data to write count is a count of bytes to write Notes: 1. This function is most effective when count is a multiple of FLASH_WRIT E_SIZE. 2. Whenever this function is about to write to a lcoation that is a multi ple of FLASH_ERASE_SIZE then a erase is performed on the whole block. The following keywords have been added to the GETENV() function: FLASH_WRITE_SIZE Smallest number of bytes that can be written to FLASH FLASH_ERASE_SIZE Smallest number of bytes that can be erased in FLASH The SETUP_CCPx and SET_PWMx_DUTY functions now work for up to 5 CCP units on chips that have them. The built in function SET_UART_SPEED now accepts a stream identifier as the second parametter. For example: SET_UART_SPEED(9600,GPS); #ORG now accepts a DEFAULT option that will cause it to apply to all functions including hidden math functions until a #ORG DEFAULT (with no address) is reached. See loader.c for an example. We added some support for PIC18 priority interrupts. You can define one interrupt as priority like this: #INT_RTCC FAST isr() { ... } A fast interrupt can interrupt another interrupt handler. The compiler does no save/restore in a fast ISR. You should do as little as possible and save any registers that need to be saved on your own.

The READ_PROGRAM_EEPROM and WRITE_PROGRAM_EEPROM functions for PIC18 now return 16 bits. The manual indicates it is 8 bits. New functions are comming that will will have more options. Arrays may be defined with [] in many cases. For const char id[] = {"Hi There"}; int x[]; int x[] = {1,2,3}; example: // Same as [9] // Same as *x // Same as [3]

The #USE I2C option NOFORCE_SW is still accepted however the new FORCE_HW is what will appear in future documentation. #INT_???? directives now allow a NOCLEAR option to prevent the compiler from clearing the interrupt. For example: #INT_RTCC NOCLEAR isr() { ... } The compiler now accepts trigraph sequences for keyboards that do not have the following: # [ ] \ ^ { } | ~ The following three character sequences are translated to the indicated one char : ??= # ??( [ ??/ \ ??) ] ??' ^ ??< { ??! | ??> } ??~ Some new functions have been added to allow for unorthodox jumps. x = label_address(label); Will return the ROM address of the label goto_address(x); Will jump to the ROM address x r = setjmp(env); longjmp(env,val); Standard C function (requires setjmp.h) Standard C function (requires setjmp.h)

Use these functions with GREAT caution. Note as well that setjmp and longjmp do not clean up the stack on 12 and 14 bit parts. The standard functions iscntrl,isgraph,isprint and ispunct are now in ctype.h. The compiler now supports the offsetof() and offsetofbit() functions. offsetof( ) requires stddef.h be included. These functions return the offset (in bytes and bits) of the field within a structure. The defines __FILE__, __LINE__ and __TIME__ are now supported. #USE RS232 has been updated to allow a stream identifier for the port. This identifier may then be used in fgetc,fgets,fprintf,and fputc to indicate what port to use for the function. For example: #use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7,stream=HOSTPC) #use rs232(baud=1200,xmit=pin_b1,rcv=pin_b0,stream=GPS)

#use rs232(baud=9600,xmit=pin_b3,stream=DEBUG) ... while(TRUE) { c=fgetc(GPS); fputc(c,HOSTPC); if(c==13) fprintf(DEBUG,"Got a CR\r\n"); } The following functions have been added to math.h: sinh, cosh, tanh, fabs, fmod, atan2, frexp, ldexp, modf The include file "errno.h" may be included to enable error checking in the math functions. Since this checking takes extra ROM the checking is only done if errno.h has been included before math.h. The function strerror() may be used to format an error message. The standard C header files float.h, limits.h, stddef.h and locale.h are provide d to make these compiler constants available to those who would like to use them. The assert macro is now supplied in assert.h. It may be used to test for a cond ition and if false will output an error on STDERR. By defualt STDERR is the first RS2 32 port defined in a program. If NODEBUG is #defined then no code is generated for the assert macro. Example: assert( number_of_entries < TABLE_SIZE ); The built-in function SPRINTF has been added. For example: char s[10]; long i; sprintf(s,"%lu",i); The built in function getenv() has value = getenv(cstring); cstring is a constant as follows: FUSE_SET:fffff FUSE_VALID:fffff INT:iiiii ID DEVICE 74") CLOCK AY) VERSION VERSION_STRING PROGRAM_MEMORY s) STACK DATA_EEPROM READ_PROGRAM PIN:pb rt ADC_CHANNELS ADC_RESOULTION D_ADC() been added. The syntax is string with a recognised keyword Returns Returns Returns Returns Returns 1 if fuse fffff is enabled 1 if fuse fffff is valid 1 if the interrupt iiiii is valid the device ID (set by #ID) the device name string (like "PIC16C

Returns the Osc clock value (from a #USE DEL Returns the compiler version as a float Returns the compiler version as a string Returns the size of memory for code (in word Returns Returns Returns Returns the the a 1 a 1 stack size number of bytes of data EERPOM if the code memory can be read if bit b on port p is on this pa

Returns the number of A/D channels Returns the number of bits returned from REA

ICD ICD SPI USB CAN I2C_SLAVE I2C_MASTER PSP COMP VREF rence LCD UART CCPx TIMERx

Returns a 1 if this is being compiled for a Returns Returns Returns Returns Returns Returns Returns Returns Returns Returns Returns Returns a a a a a a a a 1 1 1 1 1 1 1 1 if if if if if if if if the the the the the the the the device device device device device device device device device of H/W device device has has has has has has has has SPI USB CAN I2C slave H/W I2C master H/W PSP a comparator a voltage refe

a 1 the a 1 a 1

if the number if the if the

has direct LCD H/W UARTs has CCP number x has TIMER number x

Examples: #IF getenv("VERSION")<3.050 #ERROR Compiler version too old for this program #ENDIF for(i=0;i<getenv("DATA_EEPROM");i++) write_eeprom(i,0); #IF getenv("FUSE_VALID:BROWNOUT") #FUSE BROWNOUT #ENDIF The PCW IDE F4 command has been removed and replaced with a feature that allows you to move your cursor over a (,),{ or } and the matching item will highlight.

S-ar putea să vă placă și