Author Topic: Converting C30 to XC16 code..  (Read 1985 times)

0 Members and 1 Guest are viewing this topic.

Offline jcdammeyerTopic starter

  • Newbie
  • Posts: 5
  • Country: ca
Converting C30 to XC16 code..
« on: February 14, 2025, 06:24:58 am »
I've had to convert a program to compile with XC16.  Up until now it was fine with the C30 compiler on a WIN-7 system but unfortunately the WIN-7 system crashed and the ICD-3 isn't supported on the WIN-10 system.  And of course MPLAB-8 runs on WIN-10 but doesn't talk to the ICD-4.   

I've managed to link in the appropriate libraries etc so that with the C30 compiler (licensed and optimized) it now creates the program and the ICD-4 programs the PIC30F5011.  MPLAB-X no longer throws a fit.

However if I did want to update to the XC16 I can't find anything equivalent to this CAN library as documented in the C30 can.h include file.

        // Put module into Configuration mode using Microchip can.h parameters
        CAN1SetOperationModeNoWait(
            CAN_IDLE_STOP &
            CAN_MASTERCLOCK_1 &
            CAN_REQ_OPERMODE_CONFIG &
            CAN_CAPTURE_DIS_NO_WAIT
            );

Not only that, under C30 to set the configuration bits a series of macros like:
_FOSC(XT_PLL8 & PRI & CSW_FSCM_ON);

set the configuration bits but that means also adding:
#include "p30F5011.h"

The XC16 compiler uses defines.
    #pragma config FPR = XT_PLL8            // Primary Oscillator Mode (XT w/PLL 8x)
    #pragma config FOS = PRI                  // Oscillator Source (Primary Oscillator)
    #pragma config FCKSMEN = CSW_ON_FSCM_OFF// Clock Switching and Monitor (Sw Enabled, Mon Disabled)

So the question is if I want to use XC16 is there an equivalent library for CAN bus?
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3926
  • Country: it
Re: Converting C30 to XC16 code..
« Reply #1 on: February 14, 2025, 08:26:11 am »
the ICD-3 isn't supported on the WIN-10 system

ICD3 works fine under windows 10, and always had, at least under MPLABX. Not sure about MPLAB 8 as i haven't used it in ages.

other points:
- never include the device file, but only include <xc.h>
- put configuration pragmas in a c file, before any include
- be wary of any declaration that doesn't use fixed width types (those in sdtint.h), for example using char for uint8_t could be bringing you pain as the signedness of char is implementation defined
- older versions of XC16 (pre 1.35 IIRC) had the PLIB installed alongside them, slightly newer (pre 2.00) didn't but were compatible with. I think the PLIB from C30 and XC16 were compatible/the same, you might be missing those? (should be available in the XC16 downloads page, or in the MPLAB Ecosystem Archives) - Though it was never a problem for me as i learned early on how better it was to write my own libraries
- Older compiler was C90 + extensions, XC16 >= 2.00 is C99 with all the differences it brings


 
The following users thanked this post: Dazed_N_Confused

Offline jaka

  • Contributor
  • Posts: 15
  • Country: fi
Re: Converting C30 to XC16 code..
« Reply #2 on: February 14, 2025, 10:39:13 pm »
the ICD-3 isn't supported on the WIN-10 system
ICD3 works fine under windows 10, and always had, at least under MPLABX. Not sure about MPLAB 8 as i haven't used it in ages.
ICD3 works fine with MPLAB 8 too, on windows 10. And on windows 11.

Changing between MPLAB 8 and MPLAB-X is little more complicated. There is the app to change between the two, but that has not worked for me. I have had to fix the paths on ICD3_switcher64.bat and then call it from command line, as administrator.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->