CCS News RSS

Click here to view the PDF newsletters. Interested in receiving our newsletters in your inbox? Click here to subscribe.

Debugger Features You Might Not Know About

Friday 29 April, 2022

Save to notes
The option to "Save to notes" is in the right-click menu of multiple debug windows which will append the selected data (such as break log or RAM data) to the end of the notes file associated to the project.



Drag and drop "watch items"
Have an important watch variable that is in the middle or at the bottom of your watch list? You can now drag and drop watch items within the watch window to reorder them by your preference.



Change RAM
If during debugging you want to change the value of a variable or just see the result of a complex expression use the EVAL tab in the debugger. If you use the = operator then RAM is actually changed.



Viewing RAM
Looking directly at the RAM data is easy with the RAM tab in the debugger. You might not know if you highlight some data you can use right click to interpret that data in various formats or just copy the data to your notes file.



There are a lot of helpful features in the debugger, many can be explored be reviewing the various tabs and doing some right clicking. If you have suggestions for more features please let us know.



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 https://www.ccsinfo.com.

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

Debugging Support for Dual Core dsPIC33CH Family

Friday 29 April, 2022

Introducing support added for debugging dsPIC33CH devices for both the master and slave cores to the CCS C Compiler and IDE using the CCS ICD-U80 or ICD-U64 device programmers. This support will be available starting with Compiler version 5.094 and ICD firmware version 3.42 and newer. In addition to debugging the slave core with the CCS tools the slave core can also be programmed starting with the previously mentioned version. Both of these features will aid in developing code for the dsPIC33CH dual core devices.

When debugging there are three setups that can be done. First debug only the master core, second debug only the slave core, or third debug both the master and slave core at the same time. When debugging the slave core the master core's configuration bit need to be set so that the slave core can be debugged. At minimum the S1_ISOLAT, S1_DEBUG and S1_ICSPx, x being the debug pin to use for the slave core, should be set. The S1_ISOLAT configuration fuse allows the slave core to operate even if the master core hasn't set the SLVEN bit in the MSI1CON register, enabling the slave core to run, the S1_DEBUG configuration fuse enables the slave core debugger and the S1_ICSPx configuration fuses sets which S1MCLRx, S1PGCx and S1PGDx pins are being used to debug the slave core.

When debugging both the master core and slave core at the same time it requires that two instances of the CCS C Compiler and IDE be running, two device programmers, and the development board will have to have two ICD connectors on it connected to different MCLR, PGC and PGD pins, one for the master core and one for the slave core. To run two instances of the CCS C Compiler and IDE +FORCE_NEW needs added to the target line of the icon used to launch the IDE, for example:



With the above change when using that icon to start the IDE will cause a new instance of the IDE to start allowing for more the one instance to be running. Once there are two instances of the IDE running the master core project should being opened in one and the salve core project should be opened in the other. Next starting with the master core project, build it with the appropriate slave core configuration fuses set and start the debugger. Assuming both ICDs are connected to the PC a selection box similar to the following should pop up:



Select the ICD that is connected to the master core's programming/debugging pins and select 'OK'. If you're not sure which ICD is connected to the master core you may want to disconnect the ICD connect to the slave core debugging pins from the PC and then start the master core's debugger, then when the master core's debugger is loaded the slave core ICD can be reconnected to the PC. Once the master code program debugger is loaded, switch to the CCS IDE instance with the slave core project, build it and start its debugger. Once it's done loading both the master and slave core can be debugged at the same time.

One thing to be aware of the master code debugger using the MCLR pin of the PIC. If the master core's debugger pulls that pin low to reset the master core it will also reset the slave core. So if the master core debugger is reset or the program if reloaded when the slave core is also being debugged, the slave core's debugger needs to be reset to synchronize it with the slave core.



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 https://www.ccsinfo.com.

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

Debugging With Two Processors

Friday 29 April, 2022

Sometimes there is a need to debug multiple processors in the same system. It is possible if you use the CCS ICD units to use multiple ICD units on the same PC. This allows you program or debug different target devices in separate processors concurrently.

By default the PCW IDE will only open one instance and additional files you attempt to edit appear as separate tabs. Although the IDE can only manage one project at a time it is possible to have multiple instances of the IDE open at the same time.

Procedure:
* Connect two ICD units and target devices.
* Right click on the desktop icon for the IDE and select PROPERTIES.
* At the end of the target line, after the " if there is one, add a space followed by: +FORCE_NEW
* Start up the IDE by double clicking on the icon and load the first project and start debugging. With both ICD units connected you will be prompted (by serial number) for the ICD unit to use. You can use the CCSLOAD utility to give each unit a friendly name. You can also go the "Configure Port" button the control panel to switch ICD units.
* Double click again on the IDE icon and this time select the second project. You can start that debugger 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 https://www.ccsinfo.com.

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

How Long Does It Take for Code to Execute

Thursday 24 February, 2022

The PIC® instructions are very deterministic in the time they take. There are exceptions, but in general a instruction takes 4 clocks (or 2 on some 24 bit chips) and if there is a change in the program counter it take s twice as long. Counting instructions in the LST file is one way to figure out the time code takes. Consider this example from the LST file:



The IF statement takes instruction times if a==b or 4 otherwise. On a PIC18 this is 16 clocks. So if the chip oscillator (fosc) is 40mhz. Then the instruction time is 4/40000000 or 100ns. This IF statement takes 300ns or 400ns to execute. The two assignments take 400ns so in total if a==b then it takes 700ns or 400ns otherwise.

IDE users can use the code profiling tool to find out how long functions take to execute or to time how long it takes to get from one point in code to another.

Use code like the following To do timing manually:

setup_timer_1(t1_internal|t1_div_by_4); // 1us tick
set_timer1(0);
for(i=1;i<=100;i++) {
a=b;
}
overhead=get_timer1();

set_timer1(0);
clear_interrupt(int_timer1);

for(i=1;i<=100;i++) {
a=b+c;
}
time=get_timer1();
time=time-overhead;

if(interrupt_active(int_timer1))
printf("\r\nOVERFLOW");

printf("\r\nus=%6.2lw\r\n",time);


Unsigned 8 bit operations for math operations are quite fast and floating point is very slow. If possible consider fixed point instead of floating point.

For example, instead of "float cost_in_dollars;" do "long cost_in_cents;". You can also get the compiler to do the math for you by using a declaration like "long fixed(2) cost_in_dollars;"

Consider a lookup table for trig formulas instead of real time calculations (see EX_SINE.C for an example).

Note all times will vary depending on memory banks used and sometimes for multiply, divide and float operations the actual numbers will affect the time.





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 https://www.ccsinfo.com.

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

Extended RAM on 24 bit parts

Thursday 24 February, 2022

The 24 bit PIC® architecture allows for very easy access from most instructions to locations 0x0000 to 0x1FFF. There are some additional instructions to move data from a working register to a location in the 0x2000 to 0x7FFF range. Note that 0x0000 to 0x07FF (or 0x0FFF on some parts) are special function registers, not general RAM.

Some devices have more than 30K of RAM. For these devices a special method is required to access the RAM above 30K. This extended RAM is organized into pages of 32K bytes each. The only way to access that RAM from assembly is to set a page register to identify the RAM page and then use indirect addresses from 0x8000 to 0xFFFF. Note that the first page is used to map program memory into the RAM address space. The other pages are the extended RAM.



From C, the compiler will allocate variables into the first page of extended RAM only. To access additional memory special functions must be used.

The basic functions to access that RAM are:

write_extended_ram(p, addr, ptr, n);
Writes n bytes from ptr to extended RAM page p starting at address addr.

read_extended_ram(p,addr,ptr,n);
Reads n bytes from extended RAM page p starting at address addr to ptr.

The first page is 1.

Example Code:

write_extended_ram(1,0x100,WriteData,8); //Writes 8 bytes from WriteData to
//addresses 0x100 to 0x107 of
//extended RAM page 1.

read_extended_ram(1,0x100,ReadData,8); //Reads 8 bytes from addresses 0x100
//to 0x107 of extended RAM page 1
//to ReadData.




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 https://www.ccsinfo.com.

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

Capacitive Touch Technology

Thursday 24 February, 2022

The generation of Enhanced Mid-Range Family of PIC16 devices include mTouch™ Sensing technology. CCS demonstrates our uses for Capacitive Touch Development Board and compiler libraries in a fun hands-on application.

The CCS Capacitive Touch board uses the PIC16LF727 device for creating human touch applications and utilizing contact sensitive hardware. Instead of using mechanical switches or buttons that can break, the Capacitive Touch pads are activated by placing a human finger over the pad and the user's natural electrical properties generate the needed response or change.

Cut development time by utilizing specific Capacitive Touch functions built into the CCS C Compiler. The #USE TOUCH_PAD library reduces roughly 500 lines of assembly to 1 line of C code! A full version of the CCS C Compiler is available with the development kit.

The CCS Exercise tutorial contains 14 example programs that step the user through Capacitive Touch applications. Use the 16 on-board programmable capacitive pads and LCD to quickly develop "touch" applications. In addition, the board is equipped with *Tag Connect footprint for ICSP™ programming and a ICD-U64 that can be used with all Flash-supported PIC® MCU devices.

For additional information or to order today, go to: www.ccsinfo.com/Touch



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 https://www.ccsinfo.com.

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

Where in the World is Waukesha?

Wednesday 22 December, 2021

Just a few short weeks ago, Waukesha, Wisconsin became international news and most of our customers are probably not aware our facility is in Waukesha Wisconsin. Some have been asking about recent events and the city. To the curious, we wanted to share a few words here even though it will not help with your C coding.

Waukesha is just a short distance away from the more known city of Milwaukee, but alike it is named from an Native American word for "fox". Other Native American cities in this area include Pewaukee - the home of professional football player JJ and TJ Watt, Oconomowoc and also in recent news, Kenosha. Waukesha sits atop dozens of natural springs, nicknaming us Spring City. In fact our street address is Spring City Drive.

The one claim to fame the city has used to market itself, is as the home of Les Paul, the first to make an electric guitar. There is a major road renamed to Les Paul Parkway, a middle school was renamed, and there are colorful extra large guitars decorating the city.

Waukesha started out very industrious and within the past few decades, the local community has transitioned to more residential. A fairly sizable city, but with a home town feeling of coffee shops, bike paths and many new retail areas. Waukesha can boast by having 100+ year old Carroll University, as well as a large Missionary college.

So, why is everyone asking where is Waukesha? Just before Thanksgiving this past November, a man drove a red SUV through a annual Holiday Parade. People of all ages were involved and over 50 people were taken to the hospital for varying injuries. Unfortunately, five people died, including one eight-year old child. The driver was in fact, just released out on bail, again, for trying to drive over his girlfriend just the week before. The community came together and people put blue lights on their homes to show support for those that lost ones in this tragedy.

Waukesha has also had some infamous crime, including the two young girls that repeatedly stabbed a third called the "Slender Man Stabbings." Both girls were sent to a mental hospital. One is now out on the way to college and the other is being evaluated every 6 months to figure out when she has been "cured." However, in this case, the victim survived.

When we go to shows and people find out where we are, the ones who have heard of Waukesha often times know the airport as being on the way to Oshkosh (yet another Indian name). Pilots from all over the world come to Oshkosh at the end of July for the Experimental Aircraft Association Fly-In. This a huge event and makes the airport the busiest airport in the world for one week. This past July we had a booth at the show to show case DC Power and Battery analyzer equipment made by our subsidiary company, West Mountain Radio. This is a spectacular event with over 100,000 visitors a day. You can walk right up to hundreds of all types of planes, watch an air show along the mile long show runway, or even buy a plane. The view of the aircraft parking lot is amazing with uniqueness and ingenuity.

Waukesha may have some good and bad notoriety, but it is still an excellent place to work to provide quality products to our customers. So, where is Waukesha? The question is why not Waukesha?



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 https://www.ccsinfo.com.

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

About CCS: 30 Years in the Making

Wednesday 22 December, 2021

Embedded computer systems has been our passion since 1992. We were first to release a C compiler for the PIC® MCU, after switching internally from the 8051. The C compiler was designed from the bottom up around the special architecture of the PIC® MCU. The PCB compiler supported the original four Microchip parts and the PCM compiler supported the one mid-range part they offered.

Microchip continued to develop new chips with additional features, and so did CCS to support these devices. Now we support over 1000 parts from 12 bit to 24 bit opcodes. We make powerful features available for even the smallest devices. We created unique built-in functions that the user would be able to migrate to new devices with ease and less programming time. We deliver tools that do not force our users into buying bigger, and more expensive, chips every time you want to do something more advanced.

As a software compiler developer we have a unique position in the marketplace for hardware development tools that work seamlessly with the IDE compiler. CCS develops tools exclusively for the Microchip PIC® MCU. We do not produce a watered down product that is available for dozens of chip manufactures. We intentionally do not try to shoe-horn an existing compiler engine into simply working for a PIC® MCU.

CCS has a team of embedded engineers that develop the compiler and use it to produce real world applications in custom projects. We produce products that do work in the real world as opposed to products that should theoretically work. Our custom customers are on the cutting edge and need us to be ready for new protocols. This also improves the compiler so we can support these new technologies and have built-in functions and examples for our customers. We are committed to producing a compiler that is easy to use for Software Engineers, Electronic Engineers and hobbyists alike. The emphasis is on using the rich set of built-in functions that operate across all PIC® MCU families.

Approximately 11 years ago, CCS took on another endeavor, in purchasing a company in the Amateur Radio field, called West Mountain Radio. This brand focused on radio accessories including interface units from the radio to a PC. CCS was able to augment some brilliant and very popular analog designs with microprocessors (PIC® MCU's of course) to take the product lines to the next level. For example CCS took a simple power distribution unit and added internet conductivity so the power distribution could be monitored and controlled from any web browser in the world.

As a company we continue to fully support and update the product lines from both companies. We appreciate all of our supportive customers and are always willing to listen to feedback.



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 https://www.ccsinfo.com.

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

Easy Digital Filtering

Wednesday 22 December, 2021

This article gives an overview of how to implement a simple low pass and high pass filter for audio using dsPIC® processors. The example code implements a tone control pot. Center does not filter, and when turned counter-clockwise. the bass is increased and clockwise increases the trebble.

Our example uses a structure for each sample point that is a complex number. It has a real and imaginary part to allow other areas of the program that use them both. For our use we only need the real part.



The pseudo-code for a 3 pole filter looks like this:



The algorithm uses a set of coeficient constants that determine if the filter is low pass or high pass and what the cutoff frequency is. In our example we want the constants to change based on the pot setting. These constants are based on a 8khz sample rate.



The acca register is a built in accumulator in the processors with a DSP. The DSP engine has a bult in instruction to help with code like "acca += K[kp++] * window[j]." It looks like this in assembly:

mac W4*W5,A

Notice in the assembly language how C variables are referenced. Pay close attention to when pointers are being used as opposed to straight values.





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 https://www.ccsinfo.com.

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

Problems Buying Production IC's? Migrating to Newer Processors

Wednesday 22 December, 2021

Since the beginning Microchip has been great at having stock of all processors, even very old ones. That has changed over the last year as many of you have found out. If you are reading this then you probably are a CCS C compiler user. The good news is with most programs it is very easy to change from one chip to another.

For example if it is hard to buy the popular PIC16F887 part, you may be able to find the PIC16F747 and that might work for your application.

In many cases the only change you need to make is changing:

#include <16F887.h>

To:
#include <16F747.h>

Then recompile and start up the production line.

Another bonus is the newer parts seem to have more features and they are a lower cost. For example a popular 8 pin part for many classic designs uses the PIC12F675 part. The newer PIC16F18313 part is 33% lower cost with double the memory.

If you have the IDE compiler there is an easy way to find parts that might work as an alternative. Use TOOLS > DEVICE EDITOR > SELECTION TOOL

Then on the right side select the families (14 bit shown here) and the pin count range (30-47 shown here) along with anything else you want to filter by. The table shows the essential characteristics including the modules (like UART) included in the part.



This works so well because of the compiler built in functions that are customized on the fly for the chip that is being compiled. For example the built in function to read the Analog to Digital converter, read_adc().

For the 12F675 you get:



For the 16F18313 you get this with the same C code:



If you write directly to a register then you have have more trouble converting the code. For example on a PIC12F675 you might have a line like this:
#byte PORT_A = 0x05

Then you might do this in your code:
data = PORT_A;

For a PIC16F18313 the port A address is 0x0C so you could do this:
#byte PORT_A = 0x0C

Or better yet, to make the same code work on both chips:
#byte PORT_A = getenv("SFR:PORTA")

This only works if the SFR names are the same in both chips. You should also consider switching to built-ins by removing the #byte all together and in your code doing this:
data = input_a();

You can do a similar thing for bit names like this:
#bit TIMER_INT_FLAG = getenv("BIT:T1IF")

Be aware sometimes the bits, even with the same name, function differently on different chips. Taking some extra time to use built in functions can save you time in the long run.

Chips with the more advanced peripheral modules may have different options for the built in functions. It is usually easy to figure out the changes by looking at the device header in the section for the peripheral. The comparator is one module that changes a lot between chips. For example:

PIC12F675: setup_comparator( A0_A1 );
PIC16F18313: setup_comparator( CP1_A1_A0 );

Newer chips generally have new fuse settings. In general the compiler default fuses are good. You may want to review the fuses (VIEW > CONFIGURATION BITS) for the new part to make sure they are good.

If you use oscillator fuse settings we strongly recommend you remove them and use the #use delay() instead. That directive sets all the fuses and registers for the oscillator. These settings are very different between chips so using the #use delay() will make the code more portable. For example:
#use delay( crystal=8mhz, clock=32mhz )



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 https://www.ccsinfo.com.

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

 Displaying 1 to 10 (of 210 articles)   Result Pages:  1  2  3  4  5 ...  [Next >>]