View previous topic :: View next topic |
Author |
Message |
andresteff
Joined: 21 Mar 2020 Posts: 44
|
Question about CLC, PIC16F1619 |
Posted: Thu Jan 14, 2021 4:05 pm |
|
|
Hey, i have a question about the clc unit.
I use the PIC 16LF1619.
In the ccs compiler i can't find a command to connect or not connected the 4 inputs individually to the gate.
On page 447 of the datasheet it says, the pins can be connected or not connected.
The corresponding register: CLCxGLS0: GATE 1 LOGIC SELECT REGISTER.
many greetings |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Thu Jan 14, 2021 4:41 pm |
|
|
I opened the manual (F11 as I use MPLAB...) and put 'CLC' in the search box.
There were 4 entries !
Now if this doesn't work for you, you may have an older version of the compiler.
This thread has got me curious to see if I can use the CLC module to replace a 30 year old PAL device..... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19497
|
|
Posted: Fri Jan 15, 2021 8:19 am |
|
|
The selections to the gate are done with #pin_select. There are four
input function selections CLCIN0 to CLCIN3.
So to route PIN A0 to CLCIN0, you use:
#PIN_SELECT CLCIN0=PIN_A0
etc..
If you look at table 19-1 these then become the bottom 4 options here.
The alternative is to select internal functions (so oscillator, UART etc.).
So with the pins setup if required. you use
clcx_setup_input(n, selection), where 'n' is the input number, 1 to 4, and
'selection;, is one of the header defines:
Code: |
#define CLC_INPUT_CLCIN0 0
#define CLC_INPUT_CLCIN1 0x01
#define CLC_INPUT_CLCIN2 0x02
#define CLC_INPUT_CLCIN3 0x03
#define CLC_INPUT_CLC1OUT 0x04
#define CLC_INPUT_CLC2OUT 0x05
#define CLC_INPUT_CLC3OUT 0x06
#define CLC_INPUT_CLC4OUT 0x07
#define CLC_INPUT_C1OUT 0x08
#define CLC_INPUT_C2OUT 0x09
#define CLC_INPUT_COG1A 0x0A
#define CLC_INPUT_COG1B 0x0B
#define CLC_INPUT_CCP1OUT 0x0C
#define CLC_INPUT_CCP2OUT 0x0D
#define CLC_INPUT_PWM3 0x0E
#define CLC_INPUT_PWM4 0x0F
#define CLC_INPUT_SCK1 0x10
#define CLC_INPUT_SDO1_SDA1 0x11
#define CLC_INPUT_NCO 0x12
#define CLC_INPUT_ZCD 0x13
#define CLC_INPUT_U1TX 0x14
#define CLC_INPUT_U1DT 0x15
#define CLC_INPUT_TIMER4 0x16
#define CLC_INPUT_TIMER6 0x17
#define CLC_INPUT_TIMER0 0x18
#define CLC_INPUT_TIMER1 0x19
#define CLC_INPUT_TIMER2 0x1A
#define CLC_INPUT_IOCIF 0x1B
#define CLC_INPUT_ADCRC 0x1C
#define CLC_INPUT_LFINTOSC 0x1D
#define CLC_INPUT_HFINTOSC 0x1E
#define CLC_INPUT_FOSC 0x1F
|
So if you wanted to use (say) pin A0 as input 1, for CLC1, you would need:
Code: |
#PIN_SELECT CLCIN0=PIN_A0
//then
clc1_setup_input(1, CLC_INPUT_CLCIN0);
|
|
|
|
andresteff
Joined: 21 Mar 2020 Posts: 44
|
CLCxGLS0: GATE 1 LOGIC SELECT REGISTER |
Posted: Fri Jan 15, 2021 2:17 pm |
|
|
thanks, but my question was a different one.
Each gate has 4 inputs, for 4 different signals.
In the datasheet on page 440 (PIC16F1619) it says:
"Enable the chosen inputs through the four gates
using CLCxGLS0, CLCxGLS1, CLCxGLS2, and
CLCxGLS3 registers."
Each of the 4 signals of a gate can be connected or not connected.
As inverting or not inverting.
With the: CLCxGLS0: GATE 1 LOGIC SELECT REGISTER (Page 447)
I can not find a command for it! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 15, 2021 6:52 pm |
|
|
The data sheet page that you referenced corresponds to these parameters
in the 16F1619.h file.
Quote: |
/ As an alternative to the above defines any of the following can be
// OR'ed together // to enable the individual inputs to the specified gate.
#define CLC_GATE_INVERTED_INPUT_1 0x001
#define CLC_GATE_NON_INVERTED_INPUT_1 0x002
#define CLC_GATE_INVERTED_INPUT_2 0x004
#define CLC_GATE_NON_INVERTED_INPUT_2 0x008
#define CLC_GATE_INVERTED_INPUT_3 0x010
#define CLC_GATE_NON_INVERTED_INPUT_3 0x020
#define CLC_GATE_INVERTED_INPUT_4 0x040
#define CLC_GATE_NON_INVERTED_INPUT_4 0x080
#define CLC_GATE_OUTPUT_INVERTED 0x100 |
So I think this is how CCS expects you to do it:
Code: |
clc1_setup_gate(1, CLC_GATE_NON_INVERTED_INPUT_1 |
CLC_GATE_NON_INVERTED_INPUT_2 |
CLC_GATE_INVERTED_INPUT_3 |
CLC_GATE_INVERTED_INPUT_4);
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19497
|
|
Posted: Sat Jan 16, 2021 3:19 am |
|
|
and (of course) just omit the gate inputs that don't want a connection. |
|
|
|