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

Selected part does not have ICD debug capability

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



Joined: 21 Oct 2016
Posts: 22

View user's profile Send private message

Selected part does not have ICD debug capability
PostPosted: Fri Feb 09, 2018 12:16 pm     Reply with quote

Hello,
I'm using a PIC18F24K42. I have two problem on this device.
I use PCWHD v5.076 in MPLAB X v4.05.

My first problem is in debugging.
I program it without problems with ICD3 but when I do the DEBUG it does not work. The message appears:
Code:
C:\Program Files (x86)\PICC\devices\18F24K42.h:11:9:  Error#164 Selected part does not have ICD debug capability


I try to use DEBUG or NODEBUG fuses but without success.


My second problem with this device is the PWM. If I use:
Code:
#pin_select PWMxOUT = PIN_Bx
(x, y are any valid numbers)

the following message appears:
Code:
Error#7  Invalid Pre-Processor directive  Invalid Pin: PIN_B0 can not be assigned to PWM6OUT

Then I could use the CCP module in PWM mode. If I use this code:
Code:
#include <18F24K42.h>
#fuses RSTOSC_HFINTRC_64MHZ
#fuses NOLVP
#fuses NOWRT                 
#fuses NOWRTC
#use delay(clock=64000000, internal)   
void main()
{
    setup_oscillator(OSC_HFINTRC_64MHZ);
    setup_ccp2(CCP_PWM);
    setup_timer_2(T2_CLK_INTERNAL | T2_DIV_BY_16,1000,13);
    set_pwm2_duty(10);
    while(1); 
}

The PWM signal is always OFF. But without debugging I can not see the value registers.

Please, how can I solve the problem with this PIC?
Thank you very much.

Best Regards,
Donatello
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Feb 09, 2018 12:54 pm     Reply with quote

this
Error#164 Selected part does not have ICD debug capability
means exactly what is says.

Not all PICs have ICD Debugging capabilty !

this
Invalid Pin: PIN_B0 can not be assigned to PWM6OUT
means exactly what it says
That PIC cannot connect PWM6OUT to PIN_B0

Both of these are covered in the PIC datasheet 'somewhere' in the 400-500 pages. That's why you need to read the datasheet 4 or 5 times. As well you need to read the device heder file. It will explain or show avaliable fuses and register options.

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 09, 2018 1:23 pm     Reply with quote

temtronic,
The webpage for the PIC says this:
Quote:

PROGRAMMING/DEBUG FEATURES

In-Circuit Debug Integrated On-Chip
In-Circuit Serial Programing (ICSP) via Two Pins

https://www.microchip.com/wwwproducts/en/PIC18F24K42
Consult the webpage for the PIC before answering.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Fri Feb 09, 2018 3:08 pm     Reply with quote

and the reason the PWM doesn't work is simple:

setup_timer_2(T2_CLK_INTERNAL | T2_DIV_BY_16,1000,13);

What is the maximum value for the PR2 value?. 1000 won't fit.....
Donatello



Joined: 21 Oct 2016
Posts: 22

View user's profile Send private message

PostPosted: Fri Feb 09, 2018 3:54 pm     Reply with quote

Hi Ttelmah,
thank you for reply.

Any value x,y I use in:
Quote:
setup_timer_2(T2_CLK_INTERNAL | T2_DIV_BY_16, x , y);


Does not work and any combination on clock and div does not work.

After many tests and combinations, I think this device is not supported by CCS. Currently I personally do not recommend these new PIC K42 series with CCS compiler.

Donatello
newguy



Joined: 24 Jun 2004
Posts: 1899

View user's profile Send private message

PostPosted: Fri Feb 09, 2018 5:21 pm     Reply with quote

Email support@ccsinfo.com

Just sounds like they goofed. Often they can get a fix or a workaround out to you in a day or two. That said, they're closed weekends but if you send them an email this weekend they may be able to help you next week.
alan



Joined: 12 Nov 2012
Posts: 349
Location: South Africa

View user's profile Send private message

PostPosted: Sat Feb 10, 2018 12:31 am     Reply with quote

If you look at CCS website under devices supported this chip are still in Beta test and no debug support yet.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sat Feb 10, 2018 3:30 am     Reply with quote

OK. Don't have this chip to test, so can only use the MPLAB simulator.
However set it up as I would expect to, and everything looks to be right in the registers:
Code:

#include <18F45K42.h>
#device ADC=12

#FUSES NOWDT
#FUSES NOLVP
#FUSES NOWRT
#FUSES NOWRTC
#FUSES NOXINST

#use delay(internal=64000000)

#PIN_SELECT CCP2OUT=PIN_C1

void main(void)
{
    setup_ccp2(CCP_PWM);
    setup_timer_2(T2_CLK_INTERNAL | T2_DIV_BY_16,250,1);
    //max here is 255 for PR2
    set_pwm2_duty(500L); //Approx 50% mark:space
    while(TRUE)
       ;
}


Does this do anything?.
Donatello



Joined: 21 Oct 2016
Posts: 22

View user's profile Send private message

PostPosted: Wed Feb 14, 2018 1:52 pm     Reply with quote

Hi Ttelmah,
To solve the problem instead of using the CCPxOUT, I used the PWMxOUT. But PMWxOUT can only be set on A or C port, so I had to move two pins from port B on port A.

I use this code:
Code:

#include <18F45K42.h>
#device ADC=12

#FUSES NOWDT
#FUSES NOLVP
#FUSES NOWRT
#FUSES NOWRTC
#FUSES NOXINST

#use delay(clock=16000000, internal)   

#pin_select PWM5OUT=PIN_A3
#pin_select PWM6OUT=PIN_C1
#pin_select PWM7OUT=PIN_C2
#pin_select PWM8OUT=PIN_A5

#INT_TIMER1
void timer1_isr()   // it does not work properly, the oscillation is very very slow!!
{
    set_timer1(100);
   
    ms++;
    if (ms>=1000)
    {
        output_toggle(PIN_B2);
        ms=0;
    }
}


void main()
{
    setup_oscillator(OSC_HFINTRC_16MHZ);

    setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
    set_timer1(650);

    setup_timer_4(T4_CLK_INTERNAL | T4_DIV_BY_128, 194, 1); //160Hz   
    setup_timer_6(T6_CLK_INTERNAL | T6_DIV_BY_8, 129, 1); //3800Hz

    setup_pwm8(PWM_ENABLED | PWM_TIMER4);
    set_pwm8_duty(200);
    setup_pwm7(PWM_ENABLED | PWM_TIMER4);
    set_pwm7_duty(400);
    setup_pwm6(PWM_ENABLED | PWM_TIMER4);
    set_pwm6_duty(100);
    setup_pwm5(PWM_ENABLED | PWM_TIMER6);
    set_pwm5_duty(260);

    enable_interrupts(INT_TIMER1);
    enable_interrupts(GLOBAL);

    while(1);
}


Now, I have the problem with setup_timer_1, because the interrupt is very very slow. I want to set it to 1ms but the interrupt occurs after minutes.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 14, 2018 2:41 pm     Reply with quote

Hopefully someone who uses that PIC , or a close relative will reply..
I downloaded the prelim datasheet and timer one can be clocked from 16 sources! Since it appears to work though very slow, I'd say the clock source is NOT the HFOSC(16MHZ) maybe the 32KHz one. I'd dump the listing and look at the timer 1 setup code, compare to the datasheet to see what actually is being coded. It could be a typo in the device header, a compiler bug or ??
Also since it is a 16 bit timer , it might be a god idea to cast the 'preload' value as a 16bit to be sure both high and low bytes are being set. I've seen in the past where you only set the lower byte of the word and the upper byte has anything in it ! Again, a listing dump will confirm/deny IF the high byte is configured properly.

hope this helps
Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Feb 15, 2018 2:51 am     Reply with quote

Er. Well if the ms value is meant to be 'millisecs', then the value being used for the timer reset is wrong.

The timer is fed off Fosc/4. 4Mhz.

1mSec is 4000 counts.

65536-4000 = 61536.

So to give a 1mSec tick:
Code:

#INT_TIMER1
void timer1_isr()   // it does not work properly, the oscillation is very very slow!!
{
    set_timer1(get_timer1()+61536);
   
    ms++;
    if (ms>=1000)
    {
        output_toggle(PIN_B2);
        ms=0;
    }
}


Note that generally it is much easier to get a tick like this by using one of the timers that can hardware reset at a count. timer2, 4 or 6.

setup_timer_6(T6_DIV_16, 249,1);

Will give a 1mSec interrupt (4MHz/(16*250)).
Donatello



Joined: 21 Oct 2016
Posts: 22

View user's profile Send private message

PostPosted: Fri Feb 16, 2018 11:39 am     Reply with quote

If I use
Code:
set_timer1(get_timer1()+X);

where X is any 16 bit number, Timer1 interrupt always works at 4ms. Shocked

I use in interrupt routine:
Code:
set_timer1(49536);

And in main:
Code:
setup_timer_1(T1_INTERNAL | T1_FOSC | T1_DIV_BY_1);


Only T1_Internal constant is not enough, T1_FOSC is also required or other internal clock source.

Thank you

Too bad, I can not debug with this device...
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sat Feb 17, 2018 2:41 am     Reply with quote

Have you spoken to CCS about the debug?.
They sent me a set of beta code for another chip, which got me debugging, and I'd expect them to be working on this.
Donatello



Joined: 21 Oct 2016
Posts: 22

View user's profile Send private message

PostPosted: Tue Feb 20, 2018 12:16 pm     Reply with quote

Yes, I will contact CCS for debugging.
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