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

dsPIC33CH128MP506 CLC [ WORKED !!!!]
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
MCUprogrammer



Joined: 08 Sep 2020
Posts: 218

View user's profile Send private message

dsPIC33CH128MP506 CLC [ WORKED !!!!]
PostPosted: Mon Aug 15, 2022 4:59 am     Reply with quote

I want to use CLC peripheral with dsPIC33CH128MP506 processor. I want to control 1 output with signal from only 1 input. Incoming PULSE information is 400ns. 200ns ON. 200ns off. I want to capture this incoming pulse information and control the output as a toggle. How can I do it?
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard


Last edited by MCUprogrammer on Tue Aug 16, 2022 2:14 am; edited 2 times in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Aug 15, 2022 5:38 am     Reply with quote

Start by pulling the Microchip CLC configuration tool:
[url]
https://microchipdeveloper.com/8bit:clcgui
[/url]

Have a look too at their tutorials on this:
[url]
https://microchipdeveloper.com/8bit:clc
[/url]

It sounds as if you want a standard D flip flop, with it's output inverted
and fed back to it's input, so you get an inversion on every clock. Then
just feed your input signal in as the clock.

With the configuration tool you can see what logic you need, and then
just copy this into the setup_clc lines in the compiler.
MCUprogrammer



Joined: 08 Sep 2020
Posts: 218

View user's profile Send private message

PostPosted: Mon Aug 15, 2022 6:21 am     Reply with quote

I did like the example below. But it didn't work.

Code:

#include <33CH128MP506.h>
#fuses NOWDT
#device NESTED_INTERRUPTS=TRUE
#use delay(clock=180MHz, crystal=20MHz)

#define A_INPUT                       PIN_B12

#pin_select CLCINA=A_INPUT

#define LEDOUT                       PIN_B14

#pin_select CLC1OUT=LEDOUT


void main(void)
{
   //setup CLC1 inputs
   clc1_setup_input(1, CLC_INPUT_0);   //CLCINA (A_INPUT)
   //setup CLC1 gates
   clc1_setup_gate(1, CLC_GATE_NON_INVERTED_INPUT_1); //A_INPUT
   clc1_setup_gate(2, CLC_GATE_SET);
   
   //setup CLC1
   setup_clc1(CLC_ENABLED | CLC_MODE_AND | CLC_OUTPUT | CLC_OUTPUT_INVERTED);
   

   while(TRUE)
   {
   
   }
}

_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Aug 15, 2022 10:24 am     Reply with quote

You are not setting up a flip flop, so no wonder it doesn't work.

Look at this thread:

[url]
https://www.ccsinfo.com/forum/viewtopic.php?t=55128
[/url]
MCUprogrammer



Joined: 08 Sep 2020
Posts: 218

View user's profile Send private message

PostPosted: Tue Aug 16, 2022 2:13 am     Reply with quote

ok it worked. No need to flip flops. I'm approximating the incoming pulse in 100ns. If the input is 1, the output is 1. If the input is 0, the output is also 0.
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Aug 16, 2022 5:58 am     Reply with quote

You said you wanted the output to 'toggle'. That implies a flip-flop.....
MCUprogrammer



Joined: 08 Sep 2020
Posts: 218

View user's profile Send private message

PostPosted: Tue Aug 16, 2022 10:15 am     Reply with quote

That's exactly what I said. Output 1 when input is 1, output 0 when input is 0.
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
gaugeguy



Joined: 05 Apr 2011
Posts: 286

View user's profile Send private message

PostPosted: Tue Aug 16, 2022 11:19 am     Reply with quote

That sounds like a buffer
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Aug 16, 2022 11:36 am     Reply with quote

Yes, that is just a simple buffer gate, not a toggle.
MCUprogrammer



Joined: 08 Sep 2020
Posts: 218

View user's profile Send private message

PostPosted: Wed Aug 17, 2022 3:23 am     Reply with quote

I am getting this error while installing the program. What would be the reason

Code:

TEST.hex
12:20:54  Assigning chip: DSPIC33CH128MP506
12:20:54  Loaded: DSPIC33CH128MP506
12:20:55  Assigning chip: DSPIC33CH128MP506
12:20:55  Loaded: DSPIC33CH128MP506
12:20:55  Assigning chip: DSPIC33CH128MP506
12:20:55  Loaded: DSPIC33CH128MP506
12:20:57  Target Vdd = 3.25
12:20:59  Target Vdd = 3.25
12:21:00  Target Vdd = 3.25
12:21:01  Target Vdd = 3.25
12:21:03  Target Vdd = 3.25
12:21:04  Target Vdd = 3.25
12:21:06  Target Vdd = 3.25
12:21:07  Target Vdd = 3.25
12:21:09  Target Vdd = 3.25
12:21:10  Target Vdd = 3.25
12:21:13  Target Vdd = 3.25
12:21:13  Assigning chip: DSPIC33CH128MP506
12:21:13  Loaded: DSPIC33CH128MP506
12:21:13  Setting Vpp=0
12:21:13  Assigning chip: DSPIC33CH128MP506
12:21:13  Loaded: DSPIC33CH128MP506
12:21:15  Assigning chip: DSPIC33CH128MP506
12:21:15  Loaded: DSPIC33CH128MP506
12:21:15  Write FILE -> CHIP
12:21:16  Setting Vpp=0

_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Aug 17, 2022 3:39 am     Reply with quote

To have any hope at all of helping, we need to know what programmer
you are using, and what software to drive it.
Display looks like something like possibly MPLAB, rather than CCS.
Nothing there looks like an error.
MCUprogrammer



Joined: 08 Sep 2020
Posts: 218

View user's profile Send private message

PostPosted: Wed Aug 17, 2022 4:00 am     Reply with quote

CCS C 5.109

ICD U80
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Aug 17, 2022 4:15 am     Reply with quote

So, you are using the 'Program' option from inside the IDE?.
Try using CCSload directly instead.
CCSload itsefl is what is being called by this option, but run directly it is
more likely to tell you the error. It also has diagnostics allowing you to
test what is happening.
I still do not see an error being reported.

The U80 is very prone to problems if the cable or connection is not perfect.
I use cables half the length of the supplied ones, and these reduce problems
massively.
MCUprogrammer



Joined: 08 Sep 2020
Posts: 218

View user's profile Send private message

PostPosted: Wed Aug 17, 2022 5:01 am     Reply with quote

I used CCSLOAD directly. fail again
Code:

14:00:46  Param: +DEBUGLOG
14:00:47  Attempting to connect   
14:00:51  Scanning file: C:\Users\ertan\Desktop\PIC_GPIO_SPEED_TEST\DSPIC33CH128MP506 CLC\CLC TEST.hex
14:00:51  Assigning chip: DSPIC33CH128MP506
14:00:51  Loaded: DSPIC33CH128MP506
14:00:51  Assigning chip: DSPIC33CH128MP506
14:00:51  Loaded: DSPIC33CH128MP506
14:00:53  Assigning chip: DSPIC33CH128MP506
14:00:53  Loaded: DSPIC33CH128MP506
14:00:53  Write FILE -> CHIP
14:00:54  Setting Vpp=0

_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Aug 17, 2022 6:30 am     Reply with quote

So, what do the diagnostic selections say?.

Firmware up to date.
Do all the pins test correctly.

The point is that CCSLoad allows you to test things.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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