• AVR Freaks

Hot!CLC module in PIC18F27Q10 - how to Set/Reset from the code?

Author
Andy123
Super Member
  • Total Posts : 625
  • Reward points : 0
  • Joined: 2005/04/25 14:20:54
  • Status: offline
2020/09/19 18:22:57 (permalink)
0

CLC module in PIC18F27Q10 - how to Set/Reset from the code?

This is a first time I am trying to use CLC module and for test using PIC18F27Q10 board.
Trying to build shift register, so I am using 4 modules in 1-Input D-flip/flop with set reset.
See attached picture
 
The question is how to programmatically Set or Reset it without wasting a physical pin?
I can't find a mode or register in the manual that can to it.
 
Thank you. 
post edited by Andy123 - 2020/09/19 18:29:47

Attached Image(s)

#1

7 Replies Related Threads

    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: CLC module in PIC18F27Q10 - how to Set/Reset from the code? 2020/09/19 19:06:34 (permalink)
    0
    What peripherals are you NOT using in that chip?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    davea
    Super Member
    • Total Posts : 384
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: Tampa Bay FL USA
    • Status: online
    Re: CLC module in PIC18F27Q10 - how to Set/Reset from the code? 2020/09/19 19:35:42 (permalink)
    0
    you need to think outside the box
    get rid of the connection to the ????????
    OR gate #4
    run MCC and copy the clc1.c file and paste it somewhere
    set the NOT dot on OR gate #4
    run MCC again and compare the new clc1.c file to the saved file
    and see what has changed..  there's your answer
    also set the unused inputs to something internal (PWM3_OUT, LFOSC, CLC3_OUT)
    so no pins are used   
    #3
    ric
    Super Member
    • Total Posts : 28660
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: CLC module in PIC18F27Q10 - how to Set/Reset from the code? 2020/09/19 19:40:13 (permalink)
    0
    As above.
    It may also be worth checking if the LATE and PORTE bits exist for the pins that are NOT implemented on the 28 pin part.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    NorthGuy
    Super Member
    • Total Posts : 6350
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: CLC module in PIC18F27Q10 - how to Set/Reset from the code? 2020/09/19 20:20:02 (permalink)
    +3 (3)
    Set CLCxGLSy register to 0. Then you can control the input with the GyPOL bit of the CLCxPOL register (x is the CLC, y is the input).
     
    For the case on the picture, this would be CLC1GLS3 register to set to zero and CLC1POLbits.G3POL to control the input.
    #5
    Howard Long
    Super Member
    • Total Posts : 836
    • Reward points : 0
    • Joined: 2005/04/04 08:50:32
    • Status: offline
    Re: CLC module in PIC18F27Q10 - how to Set/Reset from the code? 2020/09/20 01:11:22 (permalink)
    +1 (1)
    What Northguy said. I've done exactly this in the past.
     
    For an example see my post 60 from here: https://www.microchip.com/forums/m1128578-p3.aspx
     
    I update a CLC D type flip flop D input within a timer ISR. The ISR is triggered synchronously with the D type's clock to avoid glitches and jitter).
     

    void __interrupt() MyISR(void)
    {
    LATAbits.LATA2=1; // Debug LED2

    if (PIR1bits.TMR2IF)
    {
    PIR1bits.TMR2IF=0;

    // Update 20us timer counter
    _u16Timer20us++;

    // Update the two NCOs
    _u24uNCO1Acc.u24+=_u24NCO1Inc;
    _u24uNCO2Acc.u24+=_u24NCO2Inc;

    // Update the CLC1 D type flip flop input based on the top bit of s/w NCO1.
    // The CLC buffers the state so it precisely sets when TMR2 matches, minimising jitter.
    CLC1POLbits.LC1G2POL=0;
    if (_u24uNCO1Acc.u.s.bTop)
    {
    CLC1POLbits.LC1G2POL=1;
    }

    // Update the CLC2 D type flip flop input based on the top bit of s/w NCO2.
    // The CLC buffers the state so it precisely sets when TMR2 matches, minimising jitter.
    CLC2POLbits.LC2G2POL=0;
    if (_u24uNCO2Acc.u.s.bTop)
    {
    CLC2POLbits.LC2G2POL=1;
    }

    { // One millisecond timer update
    static uint8_t u8=SAMPLE_RATE/1000;

    if (--u8==0)
    {
    u8=SAMPLE_RATE/1000;
    _u16TimerMS++;
    }
    }
    }
    LATAbits.LATA2=0; // Debug LED2
    }

    #6
    Andy123
    Super Member
    • Total Posts : 625
    • Reward points : 0
    • Joined: 2005/04/25 14:20:54
    • Status: offline
    Re: CLC module in PIC18F27Q10 - how to Set/Reset from the code? 2020/09/20 04:32:29 (permalink)
    0
    Thanks everyone for guidance.
    Since I need to Set/reset 4 triggers at the same time, I am thinking to connect unused CLC8 output to these.
    Then use Polarity change method described here in one place only. 
    I will try and let you know.
    Thanks again.
    #7
    Andy123
    Super Member
    • Total Posts : 625
    • Reward points : 0
    • Joined: 2005/04/25 14:20:54
    • Status: offline
    Re: CLC module in PIC18F27Q10 - how to Set/Reset from the code? 2020/09/20 08:02:51 (permalink)
    0
    I got this working by using unused signal to preset all 4 triggers. I also tried to change gate 3/4 polarity - all works great. Thanks again.
    Then I tried to do 4 bit reversible shift registers adding gate multiplexor between gates - see attached one pair.
    This also works, but used all 8 cells. I am using unused CPM1 POLARITY to control direction.
    Any idea on how to simplify it? 

    Just a little background: today this is done using shift left/right in interrupt routine and I am trying to avoid that.

    Attached Image(s)

    #8
    Jump to:
    © 2020 APG vNext Commercial Version 4.5