• AVR Freaks

Helpful ReplyHot!Problem with dsPIC33CK256MP508 SCCP Timer Mode

Author
hansp
Starting Member
  • Total Posts : 32
  • Reward points : 0
  • Joined: 2020/04/03 10:40:27
  • Location: Austria
  • Status: offline
2020/06/06 07:42:29 (permalink)
0

Problem with dsPIC33CK256MP508 SCCP Timer Mode

Hi,
I would like to use the SCCP in timer mode for my SW-PWM.
It worked perfectly in the PIC24. Comparison value set, then
in the interrupt routine the next timer value loaded and so on. Unfortunately, this PIC 33 does not work in this case.
If I set a new "Primary Timer Period" in the interrupt routine that only works for 3 to 4 ticks then the interrupt pauses for a long time and so on.
A change of the "Primary Timer Period" in the main loop has no effect at all.
What am I doing wrong?

BR Peter
#1
du00000001
Just Some Member
  • Total Posts : 3942
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/06 07:59:27 (permalink)
0
Which "PIC24" derivative do you compare to the dsPIC33CK ?
 
I cannot find an association of the primary timer with interrupts. So whatever you're trying to achieve is quite mysterious. Better provide your code.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#2
hansp
Starting Member
  • Total Posts : 32
  • Reward points : 0
  • Joined: 2020/04/03 10:40:27
  • Location: Austria
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/06 10:36:12 (permalink)
0
I mean the "SCC8P-PWM/Input Capture/Output Compare/Timer" module. I operate it in "timer mode" (and not in Compare / PWM or capture mode). This module triggers an interrupt as soon as the 
"Primary Timer Period" matches the timer value.
I compare this CPU with the PIC24FJ256GA7.
#3
du00000001
Just Some Member
  • Total Posts : 3942
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/06 11:20:50 (permalink)
2 (1)
Did you check the errata sheet?
 
Errata sheet dsPIC33CK...
For proper SCCP/MCCP input clock synchronization, do not use FOSC as the system clock source.


PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#4
hansp
Starting Member
  • Total Posts : 32
  • Reward points : 0
  • Joined: 2020/04/03 10:40:27
  • Location: Austria
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/06 12:12:24 (permalink) ☄ Helpfulby milstan 2020/07/20 17:17:08
0
Thanks for You tip, but I don't use clock synchronisation.

I have now tried T1CK as clock source but it doesn't work at all.
#5
Gort2015
Klaatu Barada Nikto
  • Total Posts : 3992
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/06 18:23:52 (permalink) ☄ Helpfulby milstan 2020/07/20 17:17:36
5 (1)
This will work: (Works on CH dual core)
   
IEC2bits.CCT4IE = 0;
    CCP4CON1L = _CCP4CON1L_T32_MASK;
    CCP4TMRH = 0;
    CCP4TMRL = 0;
    x--;
    CCP4PRH = x >> 16;
    CCP4PRL = x;
    CCP4CON1Lbits.CLKSEL = 2;  // FOSC ok on CH
    IFS2bits.CCT4IF = 0;
    CCP4CON1Lbits.CCPON = 1;
    while (!IFS2bits.CCT4IF);
    CCP4CON1Lbits.CCPON = 0;

 
cpu @100MHz
 
1ms =
 
0.001 / (1 / 100,000,000)
 
PR = 100,000, no prescale.
 

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
#6
Gort2015
Klaatu Barada Nikto
  • Total Posts : 3992
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/06 18:26:29 (permalink)
0
Or
 
100,000,000 * 0.001
 

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
#7
hansp
Starting Member
  • Total Posts : 32
  • Reward points : 0
  • Joined: 2020/04/03 10:40:27
  • Location: Austria
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/06 22:06:42 (permalink)
0
Hi Gort,
Thanks for your help.
But I have to ask again. With the PIC24, this command is sufficient to change the CCP "primary time period".
 
CCP4PRL = value;
 
Can you please briefly explain your program to me why I need so many instructions now for the PIC33. 
 
BR Peter
By the way, the initialization works in my program (generated ba MCC), only subsequent changes are not possible.
 
 
 
 
#8
Gort2015
Klaatu Barada Nikto
  • Total Posts : 3992
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/07 02:23:43 (permalink)
5 (1)
timer interrupt off
setup 32bit timer
tmr = 0
Set period
source clock select
 
clear interrupt flag
timer on
 
poll interrupt flag
timer off
 
Forget the pic24, pic33 has a better architecture.
 
No extra instructions compared to a pic24.
 

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
#9
hansp
Starting Member
  • Total Posts : 32
  • Reward points : 0
  • Joined: 2020/04/03 10:40:27
  • Location: Austria
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/08 09:45:46 (permalink)
0
Hi Gort,
 
thanks but it is not possible for me to change the "primary timer period" after configuration. But at the end of the interrupt routine I have to load a new value for the next PWM period. But I cannot change a value once it has been set. Not even with your program part. What the hell is going on?
 
By the way, I have already noticed that the pic 33 is faster than the pic24. A good part if i didn't have this problem.
Can it be that the configuration is locked and I have to issue a special command?
 
 
post edited by hansp - 2020/06/08 09:47:25
#10
hansp
Starting Member
  • Total Posts : 32
  • Reward points : 0
  • Joined: 2020/04/03 10:40:27
  • Location: Austria
  • Status: offline
Re: Problem with dsPIC33CK256MP508 SCCP Timer Mode 2020/06/09 11:40:15 (permalink)
0
Hello friends,
now it's working. I deleted the project and created it again. It worked right away. I have no idea what was going on but I'm really happy now.

Thank you gort and du000001 for trying my problem.
 
#11
Jump to:
© 2020 APG vNext Commercial Version 4.5