Hello.
I have a PIC32MX170F256B FC8 project with 2 rotary encoders each using IOC. An IOC portA to read one and IOC portB to read the other but the portB interrupt don't work, tried all avail 2 pin combinations for the encoder on portB. Verified encoder is working.
Also tested FC8 with ONLY 1 interrupt = port B, same.
Tried a PIC32MX270F256B same result.
Lastly tried PIC24HJ128GP202 and this works perfectly with it's single IOC set to all 4 encoder pins.
Next looked at PIC32 C code with Port A interrupts set for A0 & A1; the change notice enable bits for A are in the CNENA register
CNENA = 0x83 | (0x7,<<8)) so this seems correct from the datasheet as "3" gives 1's for A1 & A0 (this register only requires the lowest 5 bits as there are only 5 pins on port A but 2 of these are for the crystal).
However for the other IOC on Port B
CNENB = 0x0 | (0x0,<<8)) so it is not setting any bits (showing 0x0 not 0x00?)
To try this only requires selecting the chip in FC8 adding a rotary encoder to port B and setting an IOC portB, so I haven't attached any code.
Could you have a look at this please as I am out of my depth?
regards
Paul McK
PIC32MX170F256B & 270F256B IOC port B problem
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC32MX170F256B & 270F256B IOC port B problem
Hi Paul,
Thanks for letting us know, I've hopefully fixed it for you now via the update system.
Thanks for letting us know, I've hopefully fixed it for you now via the update system.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: PIC32MX170F256B & 270F256B IOC port B problem
Ben
Thanks. I tried this and the interrupts are now definitely recognised as demonstrated by the PIC rebooting every time the encoder is rotated left or right. I had a squiz at the c-code and saw CNENB = 0x60 | (0x0,<<8 which is now correct for interrupt on B5 or B6.
But what is "35" doing in
//Handler code for [IOC1]
#ifndef MX_ISR_CNB
#define MX_ISR_CNB
void __ISR(35, ipl2AUTO) _IntHandlerChangeNotification1(void)
instead of void_Change_Notice_Vector, ipl2AUTO) _IntHandlerChangeNotification1(void),
regards
Paul
Thanks. I tried this and the interrupts are now definitely recognised as demonstrated by the PIC rebooting every time the encoder is rotated left or right. I had a squiz at the c-code and saw CNENB = 0x60 | (0x0,<<8 which is now correct for interrupt on B5 or B6.
But what is "35" doing in
//Handler code for [IOC1]
#ifndef MX_ISR_CNB
#define MX_ISR_CNB
void __ISR(35, ipl2AUTO) _IntHandlerChangeNotification1(void)
instead of void_Change_Notice_Vector, ipl2AUTO) _IntHandlerChangeNotification1(void),
regards
Paul
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC32MX170F256B & 270F256B IOC port B problem
Hi Paul,
That's a very good point, well spotted and thanks for letting us know. I need to investigate further on this one. The other vectos shown are for other interrupts and so won't be working as expected.
The appears to be a single vector for all three IOC interrupt types but three individual IRQ values so I need to try and get to the bottom of this. We might end up with a single interrupt for all Ports depending on how it's done on the other devices.
#define _CHANGE_NOTICE_VECTOR 34
#define _CHANGE_NOTICE_A_IRQ 45
#define _CHANGE_NOTICE_B_IRQ 46
#define _CHANGE_NOTICE_C_IRQ 47
That's a very good point, well spotted and thanks for letting us know. I need to investigate further on this one. The other vectos shown are for other interrupts and so won't be working as expected.
The appears to be a single vector for all three IOC interrupt types but three individual IRQ values so I need to try and get to the bottom of this. We might end up with a single interrupt for all Ports depending on how it's done on the other devices.
#define _CHANGE_NOTICE_VECTOR 34
#define _CHANGE_NOTICE_A_IRQ 45
#define _CHANGE_NOTICE_B_IRQ 46
#define _CHANGE_NOTICE_C_IRQ 47
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: PIC32MX170F256B & 270F256B IOC port B problem
Ben
FYI to give more context, this extract is from an encoder & touch screen test program with (2) IOC interrupts where only IOCB doesn't work properly plus (2) timer interrupts which both work, yet all (4) have a warning that the macros may not get called?
//Handler code for [IOC1]
#ifndef MX_ISR_CNB
#define MX_ISR_CNB
void __ISR(35, ipl2AUTO) _IntHandlerChangeNotification1(void)
{
PORTB;
IFS1bits.CNBIF = 0;
FCM_fine_encoder();
}
#else
#warning "This interrupt has previously been enabled, so the macro <fine_encoder> may never get called."
#endif
//Handler code for [IOC0]
#ifndef MX_ISR_CNA
#define MX_ISR_CNA
void __ISR(_CHANGE_NOTICE_VECTOR, ipl2AUTO) _IntHandlerChangeNotification0(void)
{
PORTA;
IFS1bits.CNAIF = 0;
FCM_coarse_encoder();
}
#else
#warning "This interrupt has previously been enabled, so the macro <coarse_encoder> may never get called."
#endif
//Handler code for [TMR3]
#ifndef MX_ISR_T3
#define MX_ISR_T3
void __ISR(_TIMER_3_VECTOR, ipl1AUTO) _IntHandlerDrvTmrInstance2(void)
{
IFS0bits.T3IF = 0;
FCM_printcount();
}
#else
#warning "This interrupt has previously been enabled, so the macro <printcount> may never get called."
#endif
//Handler code for [TMR2]
#ifndef MX_ISR_T2
#define MX_ISR_T2
void __ISR(_TIMER_2_VECTOR, ipl1AUTO) _IntHandlerDrvTmrInstance1(void)
{
IFS0bits.T2IF = 0;
FCM_Touch();
}
#else
#warning "This interrupt has previously been enabled, so the macro <Touch> may never get called."
#endif
regards
Paul
FYI to give more context, this extract is from an encoder & touch screen test program with (2) IOC interrupts where only IOCB doesn't work properly plus (2) timer interrupts which both work, yet all (4) have a warning that the macros may not get called?
//Handler code for [IOC1]
#ifndef MX_ISR_CNB
#define MX_ISR_CNB
void __ISR(35, ipl2AUTO) _IntHandlerChangeNotification1(void)
{
PORTB;
IFS1bits.CNBIF = 0;
FCM_fine_encoder();
}
#else
#warning "This interrupt has previously been enabled, so the macro <fine_encoder> may never get called."
#endif
//Handler code for [IOC0]
#ifndef MX_ISR_CNA
#define MX_ISR_CNA
void __ISR(_CHANGE_NOTICE_VECTOR, ipl2AUTO) _IntHandlerChangeNotification0(void)
{
PORTA;
IFS1bits.CNAIF = 0;
FCM_coarse_encoder();
}
#else
#warning "This interrupt has previously been enabled, so the macro <coarse_encoder> may never get called."
#endif
//Handler code for [TMR3]
#ifndef MX_ISR_T3
#define MX_ISR_T3
void __ISR(_TIMER_3_VECTOR, ipl1AUTO) _IntHandlerDrvTmrInstance2(void)
{
IFS0bits.T3IF = 0;
FCM_printcount();
}
#else
#warning "This interrupt has previously been enabled, so the macro <printcount> may never get called."
#endif
//Handler code for [TMR2]
#ifndef MX_ISR_T2
#define MX_ISR_T2
void __ISR(_TIMER_2_VECTOR, ipl1AUTO) _IntHandlerDrvTmrInstance1(void)
{
IFS0bits.T2IF = 0;
FCM_Touch();
}
#else
#warning "This interrupt has previously been enabled, so the macro <Touch> may never get called."
#endif
regards
Paul
Re: PIC32MX170F256B & 270F256B IOC port B problem
Ben
Forgot to add, if IOC B is enabled along with the timer interrupts, the PIC reboots on encoder CW or CCW rotation, but with the other encoder added as IOC A it works OK on that encoder but now when the IOC B encoder is operated nothing is read, the PIC freezes & doesn't reboot.
Paul
Forgot to add, if IOC B is enabled along with the timer interrupts, the PIC reboots on encoder CW or CCW rotation, but with the other encoder added as IOC A it works OK on that encoder but now when the IOC B encoder is operated nothing is read, the PIC freezes & doesn't reboot.
Paul