• AVR Freaks

Hot!input capture

Author
horkesley
Super Member
  • Total Posts : 285
  • Reward points : 0
  • Joined: 2008/09/09 00:13:17
  • Location: Essex,UK
  • Status: offline
2020/04/04 02:59:07 (permalink)
0

input capture

Hi, I have moved this thread from XC32 to here this is properly a better forum.
PIC32mx360f512.
XC32 v2.4
MPLAB 5.35
iMAC Catalina
The interrupt does not trigger.



void init_input_capture(void)
 {
    
     __builtin_disable_interrupts();
   //CNCON.CN=1;
   IC1CONSET=0x8000; //turn input capture on bit15
   CNENSET=0x01; //port RD8, ic1 bit 1 ok
   //CNENbits.CNEN2=1; //port RD9, ic2
   //CNENbits.CNEN3=1; //port RD10, ic3
   //CNENbits.CNEN4=1; //port RD11, ic4
   //CNENbits.CNEN5=1; //port RD12, ic5
    
   IC1CONSET=0x1000; //First rising edge bit 9 ok
   IC1CONCLR=0x0060; //Interrupt on every event bits 5,6
   IC1CONCLR=0x0001; //capture every edge bit 0,1,2 bit 1 ok
   IPC6SET=0x00140000; //priority 5 ok bits 20-19-18 0x101
   IPC6SET=0x0001; //sub prioriy bit 1
  
   IEC0SET=0x20; // "enable ic1" interrupts bit 5 ok
   IEC1SET=0x0001; //enable interrupt for cn1 bit 1 ok
   INTCONSET=0x01000; //Enable multi vector interrupts bit 12 ok
   __builtin_enable_interrupts();
   
     //IFS1bits.CNIF=1; //Sanity check, causes interrupt, this works
                                //otherwise code does not interrupt.
 }

void __ISR(_TIMER_1_VECTOR, ipl5SOFT)_Timer1Handler(void)
//void Timer1_interrupt() iv IVT_Timer_1 iLevel 7 ics ICS_SRS
  {
    IFS0bits.T1IF=0; //clear interrupt
    
    LED1_LAT ^=1; //toggle led see interrupt
}

void __ISR(_CHANGE_NOTICE_VECTOR, IPL5SOFT) CNISR(void)
//void __ISR( _CHANGE_NOTICE_VECTOR,IPL3{AUTO|SOFT|SRS|SAVEALL)
{
    int a;
    a=PORTD;
   
    IFS1CLR=0x0001; //clear interrupt
    input_capture(); //deal with cn interrupt
}
#1

1 Reply Related Threads

    horkesley
    Super Member
    • Total Posts : 285
    • Reward points : 0
    • Joined: 2008/09/09 00:13:17
    • Location: Essex,UK
    • Status: offline
    Re: input capture 2020/04/04 03:03:17 (permalink)
    0
    Sorry, posted incorrectly.
     
    Cut and paste issue.
    post edited by horkesley - 2020/04/04 03:04:26
    #2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5