| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| MCUprogrammer 
 
 
 Joined: 08 Sep 2020
 Posts: 233
 
 
 
			    
 
 | 
			
				| dsPIC33CH128MP506  CLC [ WORKED !!!!] |  
				|  Posted: Mon Aug 15, 2022 4:59 am |   |  
				| 
 |  
				| 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: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Aug 15, 2022 5:38 am |   |  
				| 
 |  
				| 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: 233
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Aug 15, 2022 6:21 am |   |  
				| 
 |  
				| 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: 19966
 
 
 
			    
 
 |  | 
	
		|  | 
	
		| MCUprogrammer 
 
 
 Joined: 08 Sep 2020
 Posts: 233
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue Aug 16, 2022 2:13 am |   |  
				| 
 |  
				| 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: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue Aug 16, 2022 5:58 am |   |  
				| 
 |  
				| You said you wanted the output to 'toggle'. That implies a flip-flop..... |  | 
	
		|  | 
	
		| MCUprogrammer 
 
 
 Joined: 08 Sep 2020
 Posts: 233
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue Aug 16, 2022 10:15 am |   |  
				| 
 |  
				| 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: 350
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue Aug 16, 2022 11:19 am |   |  
				| 
 |  
				| That sounds like a buffer |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue Aug 16, 2022 11:36 am |   |  
				| 
 |  
				| Yes, that is just a simple buffer gate, not a toggle. |  | 
	
		|  | 
	
		| MCUprogrammer 
 
 
 Joined: 08 Sep 2020
 Posts: 233
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Aug 17, 2022 3:23 am |   |  
				| 
 |  
				| 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: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Aug 17, 2022 3:39 am |   |  
				| 
 |  
				| 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: 233
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Aug 17, 2022 4:00 am |   |  
				| 
 |  
				| CCS C 5.109 
 ICD U80
 _________________
 Best Regards...
 MCUprogrammer
 _______________________________
 Work Hard
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Aug 17, 2022 4:15 am |   |  
				| 
 |  
				| 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: 233
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Aug 17, 2022 5:01 am |   |  
				| 
 |  
				| 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: 19966
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Aug 17, 2022 6:30 am |   |  
				| 
 |  
				| 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.
 |  | 
	
		|  | 
	
		|  |