CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

NEW 24-BIT PCHWD COMPILER BLUES

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Bill_Smith



Joined: 06 Feb 2004
Posts: 26
Location: Curitiba, Brazil

View user's profile Send private message Visit poster's website

NEW 24-BIT PCHWD COMPILER BLUES
PostPosted: Thu Jul 26, 2007 12:27 pm     Reply with quote

I have been patiently wait for the release of the 24-bit PIC compiler since it was announced over two years ago. Yesterday I received my upgrade notice from CCS and promptly ordered it. The download and installation went smoothly and I was excited to see that the current dsPIC controller that I am working with, the dsPIC30F2020, was supported.

Generally, the first thing I try when using the CCS C Compiler on a new controller is to load some simple code to toggle a single I/O pin. This proves that the compiler can compile, the target has the basic necessities of life, and the timing is correct. In my experience, if you can get this simple little program to run and produce the desired output clock signal, with the right period, then there is a pretty good chance that other programs will run fine.

I am using the dsPIC30F2020 which has a built-in 1% accurate fast RC oscillator and PLL. Very cool since you don't need a crystal to run at 30MIPS. It is also able to operate with Vdd voltages between 2.5V and 5.5V so its a nice transition part from the PIC18Fs. It is primarily targeted for digitally controlled switching power supplies, but that's not the focus of this thread.

So my first problem with the new CCS 24-bit Compiler was to figure out how to setup the #use delay and #fuse statements. Since the dsPIC30F2020 has several clocking options, I figured that I had better take a look at the 30F2020.h device file. Well, that turned out to be sparsely commented, if not confusing. The help file looks the same as before my upgrade, with nothing to indicate that I am even using a compiler for dsPICs. There is a small transition manual that pops up when you install the upgrade, but it does not go into any depth about how to address any of the 16-bit processor issues. There is only one small example program for a dsPIC30Fxxxx which doesn't show you very much either.

So I tried setting the #use delay and #fuses for FRC + PLL, HIGH RANGE, for a instruction clock of 30MHz. Entering these values didn’t work, as I received an error that I could not program the part with these fuse values. Fine, so I commented the fuses statement out and used MPLAB’s fuse configuration window. Trying to compile again pointed me to yet another error, this time in the 30F2020.h device file. After commenting out these lines, I was able to compile my program and download it to the target via my Real ICE emulator.

//#bit COMPARATOR1_RESULT GETENV('SFR:CMCON').6
//#bit COMPARATOR2_RESULT GETENV('SFR:CMCON').7

Checking the RB5 I/O pin revealed a clock signal, but certainly not with the expected period of 20ms. It was something more like 7.76us… totally off. I then tried several #use delay and delay combination values, finally arriving at #use delay(clock=120000000) together with delay_us(10) which produced a nice clock with a period of 20us. Changing the delay statements back to the originally intended delay_ms(10) didn’t change the period at all!

Code:
#include <30F2020.h>
#use delay(clock=30000000)
//#fuses FRC_PLL,FRANGE_HIGH,NOPROTECT,NOWDT,PUT128,OSCIO,DEBUG,ISC1

//--------------------------------------------------------------------------------------
// DEFINES & MACROS
//--------------------------------------------------------------------------------------
#define                                CSBAR_HIGH                     output_high(PIN_B5)   
#define                                CSBAR_LOW                      output_low(PIN_B5)     

void main(void)
{
                set_tris_b(0b0000000000000011);

while(TRUE)
                {
                                CSBAR_HIGH;
                                delay_ms(10);
                                CSBAR_LOW;
                                delay_ms(10);   
                }// End While
}// End Main Loop


Confused and disappointed, I switched back to using the Microchip C30 compiler, compiled and downloaded the equivalent code to see that it ran fine on my SMPS target board, and at the right clock period.

I also had a problem with a simple I2C Master test, which did not run at all. Similar code compiled with Microchip’s C30 compiler ran fine on my target board.

Code:
#include <30F2020.h>
#use delay(clock=120000000)
//#fuses FRC_PLL,FRANGE_HIGH,NOPROTECT,NOWDT,PUT128,OSCIO,DEBUG,ISC1
#use I2C(MASTER,SDA=PIN_F7,SCL=PIN_F8,FORCE_HW,SLOW)

void main(void)
{
   set_tris_b(0b0000000000000011);
   set_tris_f(0b0000000011000000);
   
   while(TRUE)
   {
      i2c_start();
      i2c_write(0x22);      // Device address
      i2c_stop();

      delay_ms(100);   
   }// End While
}// End Main Loop


I have always found the CCS C Compiler easier and more intuative to use than the Microchip C18 and C30 compilers, and I was really looking forward to using the new PCHWD Add-on, but I guess it will be some time before there are enough of us with experience with it to be able to share our knowledge.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

To Darren & Co.
PostPosted: Thu Jul 26, 2007 12:58 pm     Reply with quote

Darren,

Regarding the NEW 24-BIT PCD COMPILER and dsPIC issues, I suggest you to open
a new separate section in the CCS Forum Index.

Many thanks in advance,

Humberto
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 26, 2007 1:25 pm     Reply with quote

Humberto,
You should send Darren a PM about it. Then he'll be sure to see it.
Laurent Chouinard



Joined: 12 Sep 2003
Posts: 43

View user's profile Send private message

PostPosted: Thu Jul 26, 2007 2:14 pm     Reply with quote

The project status page indicates that many components are not even coded entirely, and many more are not tested entirely. We're in for a "public beta" of quite some time.

Only a few versions ago I had to dump version 4 and move back to 3 because of complex bugs that were still not resolved. I love this compiler, but I honestly do not think we're less than a year away from a stable enough compiler for the PIC24.

I too, am anxiously waiting for that to buy a few licenses and upgrade my platform. I've hit the ceiling of the biggest PIC18 chips and i'm nowhere near the end of the product requirements I need, so I desperately need a beefier chip.

I may need to get away from the Microchip family entirely.
Bill_Smith



Joined: 06 Feb 2004
Posts: 26
Location: Curitiba, Brazil

View user's profile Send private message Visit poster's website

PostPosted: Thu Jul 26, 2007 2:48 pm     Reply with quote

Laurent,

My good friends in Chandler inform me that at this year's Masters Conference they will announce the PIC32Fxxxx family. We will of course have to wait another 5 years for a CCS compiler for this, so investing the time to learn the C30 and C32 compilers is probably not a bad idea.

C'est La Vie!
Laurent Chouinard



Joined: 12 Sep 2003
Posts: 43

View user's profile Send private message

PostPosted: Thu Jul 26, 2007 2:53 pm     Reply with quote

I don't want to bring a chip debate on this private and free forum, but out of curiosity (because really, I am clueless), what other alternatives are there on the market that offer a powerful microcontroller (such as Microchip' PIC24/dsPIC) and a powerful and highly integrated compiler (such as CCS)?

I mean, I know I could just grab Microchip C compiler, or HI-TECH or IAR, but they all lack the functionality level that CCS has. Port management, serial functions, i2c, the list goes on. CCS really made something that appeals to me and I would hate to reinvent to wheel making a "i2c_stop" function or something like that.

So, what else there is on the market that would fall in these criteria?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group