• AVR Freaks

Hot!Cannot clear CCPxTMRL by software in DSPIC33CH512MP506

Author
Dima
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2019/11/25 06:34:08
  • Location: 0
  • Status: offline
2019/11/26 02:48:31 (permalink)
0

Cannot clear CCPxTMRL by software in DSPIC33CH512MP506

I have a problem clearing the timer register of the MTP module. in the datasheet indicates that the register is R/W, but when the CCPxTMRL = 0 command is executed, the register is reset to zero at the next input pulse.
 
Мodule setup code:
void SCCP3_TMR_Initialize(void)
{
// CCPON enabled; MOD 16-Bit/32-Bit Timer; CCSEL disabled; CCPSIDL disabled; TMR32 16 Bit; CCPSLP disabled; TMRPS 1:1; CLKSEL T1CK; TMRSYNC disabled; 
CCP3CON1L = (0x8700 & 0x7FFF); //Disabling CCPON bit
//RTRGEN disabled; ALTSYNC disabled; ONESHOT disabled; TRIGEN disabled; IOPS Each Time Base Period Match; SYNC None; OPSRC Timer Interrupt Event; 
CCP3CON1H = 0x00;
//ASDGM disabled; SSDG disabled; ASDG 0; PWMRSEN disabled; 
CCP3CON2L = 0x00;
//ICGSM Level-Sensitive mode; ICSEL IC3; AUXOUT Disabled; OCAEN disabled; OENSYNC disabled; 
CCP3CON2H = 0x00;
//OETRIG disabled; OSCNT None; POLACE disabled; PSSACE Tri-state; 
CCP3CON3H = 0x00;
//ICDIS disabled; SCEVT disabled; TRSET disabled; ICOV disabled; ASEVT disabled; TRIG disabled; ICGARM disabled; TRCLR disabled; 
CCP3STATL = 0x00;
//TMR 0; 
CCP3TMRL = 0x00;
//TMR 0; 
CCP3TMRH = 0x00;
//PR 65535; 
CCP3PRL = 0xFFFF;
//PR 0; 
CCP3PRH = 0x00;
//CMP 0; 
CCP3RAL = 0x00;
//CMP 0; 
CCP3RBL = 0x00;
//BUF 0; 
CCP3BUFL = 0x00;
//BUF 0; 
CCP3BUFH = 0x00;
CCP3CON1Lbits.CCPON = 0x1; //Enabling CCP
IFS2bits.CCP3IF = 0;
IFS2bits.CCT3IF = 0;
}
 
Where is the mistake?
 
#1

3 Replies Related Threads

    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Cannot clear CCPxTMRL by software in DSPIC33CH512MP506 2019/11/26 14:20:29 (permalink)
    0
    Dima
    ...
    when the CCPxTMRL = 0 command is executed, the register is reset to zero at the next input pulse.

    How do you know?
    i.e. what precise test are you doing to determine that this is happening?
     

    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
    Dima
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/11/25 06:34:08
    • Location: 0
    • Status: offline
    Re: Cannot clear CCPxTMRL by software in DSPIC33CH512MP506 2019/11/27 00:17:04 (permalink)
    0
    DSPIC33CH512MP506 slave core.
    PPS config:
    __builtin_write_RPCON(0x0000); // unlock PPS
    RPINR0bits.INT1R = 0x003F; //RC15->EXT_INT:INT1
    RPINR6bits.TCKI4R = 0x003E; //RC14->SCCP4:S1TCKI4
    RPINR4bits.TCKI2R = 0x003E; //RC14->SCCP2:S1TCKI2
    RPINR5bits.TCKI3R = 0x003F; //RC15->SCCP3:S1TCKI3
    __builtin_write_RPCON(0x0800); // lock PPS
     
    I send pulses from the sensor to the port.
    When pulses stop, I need to reset the register to count the next pulses, but the register is reset to zero on third pulse.

     
    I do not know what the problem is.
    post edited by Dima - 2019/11/27 00:21:35

    Attached Image(s)

    #3
    Dima
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/11/25 06:34:08
    • Location: 0
    • Status: offline
    Re: Cannot clear CCPxTMRL by software in DSPIC33CH512MP506 2019/12/02 05:16:36 (permalink)
    0
    can anyone help with solving this problem?
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5