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 support@ccsinfo.com

Present status of PIC24F support with PIC C compiler

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







Present status of PIC24F support with PIC C compiler
PostPosted: Wed Aug 27, 2008 5:50 am     Reply with quote

Hello,

I set up a test project with a PIC24F192GA106 with most recent PCD version 4.078. I hoped to find built-in functions for basic services, e. g. UARTs and hopefully the PIC24 specific peripheral pin select operation.

Some first observations:

I started with very basic input() and output_low()/output_high() functions. This failed, cause the compiler was accessing wrong register addresses for the port bits 8 to 15, so I defined the IO registers by myself.

The #use_rs232 allows only for UART1, although the chip has four UARTs.
Surprinsingly, it actually accesses UART2 registers, so the interrupts have to be setup as #INT_RDA2 and #INT_TBE2.

The interrupts for UART3/4 are unknown by the compiler. If I select a
GB chip (with USB interface), the UART 3/4 interrupts can be defined. The different chip handling is apparently built-in, not changable by the device *.h file.

I copied some stuff from a PIC18 project, e.g. a command line parser, that uses a strcopy from const strings (in ROM) to a RAM buffer. The string "hello\0" is copied to "hhlloo", accessing the even byte instead of the odd byte in bytewise copy action.

So, from first impression, a lot of unexpected low level programming work and invention of workarounds is necessary to start a PIC24F project with PIC C.

The ICD-U40 isn't recognizing the device at all, but this may be an issue of the specific ICD exemplar, a support case is pending. As a good thing, the MPLAB integration works O.K. with MPLAB V8.10 and the actual plugin.
As I'm mostly using MPLAB/ICD2 for programming/debugging, I'm not stuck to the ICD-U40.

I'm basically looking forward to a CCS PIC24F support with a quality as usual for PIC16/18, but I wonder when it will be ready?

Regards,
Frank
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Aug 28, 2008 3:20 am     Reply with quote

Hello,

I found, why the strcpy() from ROM table to RAM failed. I had used a typedef in table definition:
Code:
typedef char CMD[4];
typedef enum eCMD {
          cRES,cVER,cTST,
          cLAST};
const CMD cmds[cLAST] = {
         "RES","VER","TST"};

Unfortunately, PCD is ignoring the char size in internal operations. This defintion works O.K.
Code:
 const char cmds[cLAST][4] = {


Another bug exists with argument and pointer sizes. In my original function definition as shown below, the **buf entity, which should be char according to the C standard is assumed to be int16 by PCD. When *buf is odd, an Address error trap is generated, cause an illegal word copy to an odd address is performed.
Code:
typedef char *pchar;
int16 get_value(pchar *buf);


I thought, O.K., that's the typedef & char issue and wrote it without typedef:
Code:
int16 get_value(char **buf);

But now, *buf and **buf are both treated as int8, although PCD has no int8 pointers at all, resulting in accessing a wrong address.

Apparently the double indirection in function arguments doesn't work at all. I had to change it to a single indirection and edit the code also in all references to the function. All these stuff has been working with PIC16 and PIC18 and a lot of other processors since many years.
Code:
int16 get_value(int16 *pbuf);


I hope, not to find too much more bugs of this kind. At least, I got the opportunity to learn about the operation of PIC24F Address Error Trap and how to trace it in the debugger.

Regards,
Frank
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Sep 12, 2008 3:07 am     Reply with quote

No changes with V4.079 in this respect. 24FJ192GA106.h has a new date but is unchanged (and incomplete as before). You must use a wrong devices (24FJ192GB106) include file, if you want to define an UART3 interrupt. Fortunately, this seems possible without causing other issues. The problem is not to know, what may be missing too before finishing the project.

I fear, we must be prepared to switch the project to C30 if new issues arise.
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