CCS News

CCS C Supports the PIC12(L)F1612 and PIC16(L)F1613 Devices

Monday 28 April, 2014

The Microchip PIC12(L)F1612 and PIC16(L)F1613 PIC® MCUs have recently been added to the PCM compiler. Some of the unique peripherals that these devices have are an 8-bit Digital-to-Analog Converter (DAC) Module, a Zero-Cross Detection (ZCD) Module, a Cyclic Redundancy Check (CRC) Module, a 24-bit Signal Measurement Timer (SMT) and a Windowed Watchdog Timer (WDT). All are fully supported by the compiler's built in functions.

These devices are the first Midrange 8-bit class chips to have a CRC hardware module. The CRC module has a configurable 17 bit polynomial, standard or reverse bit order and software loadable data registers. The CCS C compiler provides the following functions for setting up and using the CRC module: setup_crc(), crc_init() and crc_calc(). The setup_crc() function is used to set the CRC polynomial, for example setup_crc(16, 15, 2, 0); will set the CRC polynomial of x16 + x15 + x2 + 1. The crc_init() function is use to set the starting value, and the crc_calc() function is used to calculate the CRC.

The following is an example of how to setup the CRC module with the CRC-16 polynomial x16 + x15 + x2 + 1, to initialize the CRC to zero and then to calculate the CRC for the data bytes 0x55, 0x66, 0x77 and 0x88:

unsigned int8 CRCData[4] = {0x55,0x66,0x77,0x88};
unsigned int16 CRCResult;

setup_crc(16, 15, 2, 0);

CRCResult = crc_calc(CRCData, 4, 8);

The SMT peripheral is a new peripheral that can be used as a 24-bit timer, or it can be setup to measure a variety of digital signal parameters such as pulse width, frequency and duty cycle, and the time difference between edges on two signals. The CCS C compiler provides the following functions for setting up and using the SMT module: setup_smt1(), setup_smt2(), smt1_start(), smt2_start(), smt1_read(), smt2_read(), smt1_write(), smt2_write(), smt1_status() and smt2_status(). The setup_smt1() and setup_smt2() functions are used to setup the SMT1 and SMT2 peripherals. The smt1_start(), smt2_start, smt1_stop() and smt2_stop() functions are used to start and stop the SMT1 and SMT2 peripherals. The smt1_read() and smt2_read() functions are used to read the SMT1 and SMT2 captured period and captured pulse width registers. The smt1_write() and smt2_write() functions are used to set the SMT1 and SMT2 timer and period registers. The smt1_status() and smt2_status() functions returns the status of the SMT1 and SMT2 peripherals.

The following is an example of how to setup the SMT1 peripheral to continuously read the period and duty cycle of input signal on the SMTSIG1 pin, and how to read the captured period and duty cycle from the peripheral:

unsigned int32 Period;
unsigned int32 DutyCycle;


Period = smt1_read(SMT_CAPTURED_PERIOD_REG);
DutyCycle = smt1_read(SMT_CAPTURED_PULSE_WIDTH_REG);

We invite you to visit the CCS Devices Supported page for more information on the devices that the CCS C Compilers support. Feel free to visit the Compiler product pages for more information as well.

Like us on Facebook. Follow us on Twitter.

About CCS:

CCS is a leading worldwide supplier of embedded software development tools that enable companies to develop premium products based on Microchip PIC® MCU and dsPIC® DSC devices. Complete proven tool chains from CCS include a code optimizing C compiler, application specific hardware platforms and software development kits. CCS' products accelerate development of energy saving industrial automation, wireless and wired communication, automotive, medical device and consumer product applications. Established in 1992, CCS is a Microchip Premier 3rd Party Partner. For more information, please visit

PIC® MCU, MPLAB® IDE, MPLAB® ICD2, MPLAB® ICD3 and dsPIC® are registered trademarks of Microchip Technology Inc. in the U.S. and other countries.