|
|
View previous topic :: View next topic |
Author |
Message |
Ron Guest
|
F452 RDA interrupt error |
Posted: Thu Oct 17, 2002 2:16 am |
|
|
Hello,
Do I have to add Disable_interrupts(global) and Enable_interrupts(global) at the start and end of my IntRDA_handle()?
If I don't, sending chars too fast causes a lock up of RS232 comms for a few seconds.
I use v3.089 and am porting from 16f877 to 18f452.
This is the erratic code:
.................... #INT_RDA
.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
.................... void IntRDA_handle(void)
.................... {
.................... // Disable_interrupts(global);
.................... toRxbuff(Getc());
*
034A: GOTO 0304
034E: MOVFF 01,117
0352: MOVFF 117,118
0356: GOTO 0322
.................... if (Rxispartfull())
035A: MOVF xB6,W
035C: SUBLW 14
035E: BTFSC FD8.0
0360: GOTO 0368
.................... {
.................... // set your handshake here
.................... Output_high(RTS);
0364: BCF F94.5
0366: BSF F8B.5
.................... }
.................... // Enable_interrupts(global);
0368: BCF F9E.5
036A: GOTO 0058
.................... }
This code works: (added dis/enable global interrupts)
.................... #INT_RDA
.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
.................... void IntRDA_handle(void)
.................... {
.................... Disable_interrupts(global);
*
034A: BCF FF2.6
034C: BCF FF2.7
034E: BTFSC FF2.7
0350: GOTO 034C
.................... toRxbuff(Getc());
0354: GOTO 0304
0358: MOVFF 01,117
035C: MOVFF 117,118
0360: GOTO 0322
.................... if (Rxispartfull())
0364: MOVF xB6,W
0366: SUBLW 14
0368: BTFSC FD8.0
036A: GOTO 0372
.................... {
.................... // set your handshake here
.................... Output_high(RTS);
036E: BCF F94.5
0370: BSF F8B.5
.................... }
.................... Enable_interrupts(global);
0372: MOVLW C0
0374: IORWF FF2,F
0376: BCF F9E.5
0378: GOTO 0058
.................... }
___________________________
This message was ported from CCS's old forum
Original Post ID: 7910 |
|
|
R.J.Hamlett Guest
|
Re: F452 RDA interrupt error |
Posted: Thu Oct 17, 2002 2:36 am |
|
|
:=Hello,
:=
:=Do I have to add Disable_interrupts(global) and Enable_interrupts(global) at the start and end of my IntRDA_handle()?
:=
:=If I don't, sending chars too fast causes a lock up of RS232 comms for a few seconds.
:=
:=I use v3.089 and am porting from 16f877 to 18f452.
:=
:=This is the erratic code:
:=
:=.................... #INT_RDA
:=.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
:=.................... void IntRDA_handle(void)
:=.................... {
:=.................... // Disable_interrupts(global);
:=.................... toRxbuff(Getc());
:=*
:=034A: GOTO 0304
:=034E: MOVFF 01,117
:=0352: MOVFF 117,118
:=0356: GOTO 0322
:=.................... if (Rxispartfull())
:=035A: MOVF xB6,W
:=035C: SUBLW 14
:=035E: BTFSC FD8.0
:=0360: GOTO 0368
:=.................... {
:=.................... // set your handshake here
:=.................... Output_high(RTS);
:=0364: BCF F94.5
:=0366: BSF F8B.5
:=.................... }
:=.................... // Enable_interrupts(global);
:=0368: BCF F9E.5
:=036A: GOTO 0058
:=.................... }
:=
:=
:=This code works: (added dis/enable global interrupts)
:=
:=.................... #INT_RDA
:=.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
:=.................... void IntRDA_handle(void)
:=.................... {
:=.................... Disable_interrupts(global);
:=*
:=034A: BCF FF2.6
:=034C: BCF FF2.7
:=034E: BTFSC FF2.7
:=0350: GOTO 034C
:=.................... toRxbuff(Getc());
:=0354: GOTO 0304
:=0358: MOVFF 01,117
:=035C: MOVFF 117,118
:=0360: GOTO 0322
:=.................... if (Rxispartfull())
:=0364: MOVF xB6,W
:=0366: SUBLW 14
:=0368: BTFSC FD8.0
:=036A: GOTO 0372
:=.................... {
:=.................... // set your handshake here
:=.................... Output_high(RTS);
:=036E: BCF F94.5
:=0370: BSF F8B.5
:=.................... }
:=.................... Enable_interrupts(global);
:=0372: MOVLW C0
:=0374: IORWF FF2,F
:=0376: BCF F9E.5
:=0378: GOTO 0058
:=.................... }
Have you got another interrupt set to use the 'Fast' option?. If not, disabling the interrupts, should make no difference. On the 18F family, there are two interrupt priorities. A 'fast' handler, can interrupt a 'slow' handler. Using disable interrupts, prevents this.
So what headers have you used for the other interrupt routines?.
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 7911 |
|
|
Ron Guest
|
Re: F452 RDA interrupt error |
Posted: Thu Oct 17, 2002 2:49 am |
|
|
Hi R.J,
Thanks for the fast reply.
The RDA interrupt is the only interrupt I use!? No priorities set.
Have you got any clue?
Regards,
Ron
___________________________
This message was ported from CCS's old forum
Original Post ID: 7913 |
|
|
R.J.Hamlett Guest
|
Re: F452 RDA interrupt error |
Posted: Thu Oct 17, 2002 3:17 am |
|
|
:=Hi R.J,
:=
:=Thanks for the fast reply.
:=
:=The RDA interrupt is the only interrupt I use!? No priorities set.
:=
:=Have you got any clue?
In which case, I'm afraid the answer is going to lie in what happens in the subroutines. There are significant problems with the current interrupt handler (some of which are still there in the latest 3.115 release...). By disabling interrupts, you are presumably preventing one of these problems from occurring!...
Without seeing the code used in the subroutines, it is difficult to know which routine is likely to be causing the problem, but at present the only solution, is to 'bodge round it', either by using the disable interrupt code, or by writing your own interrupt handler...
You should 'flag' this as an error to CCS.
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 7915 |
|
|
Regan Ryan Guest
|
Re: F452 RDA interrupt error |
Posted: Thu Oct 17, 2002 3:21 am |
|
|
:=Hi R.J,
:=
:=Thanks for the fast reply.
:=
:=The RDA interrupt is the only interrupt I use!? No priorities set.
:=
:=Have you got any clue?
:=
:=Regards,
:=Ron
Ron, this code works for me. I don't use the CCS built-in functions. I just address the various control bits and registers directly.
////////////////////////////////////////////////////////////////////////////////
#int_rda
void com_rxisr() // comms receive interrupt handler
{
if (bit_test(RCSTA,OERR)||bit_test(RCSTA,FERR))
{
bit_clear(RCSTA,CREN); // error has occurred, reinstate UART
bit_set(RCSTA,CREN);
bit_set(com_flags,COM_RXERR); // flag the error
com_rxc=RCREG; // clear out receive register
}
else
{
if (com_rxfree) // check if we have space
{
com_rxbuf[com_rxwrite++]=RCREG; // save new char in buffer
if (com_rxwrite==COM_RXSIZE) // update buffer pointers
com_rxwrite=0;
com_rxfree--;
}
else bit_set(com_flags,COM_RXERR); // overflow, couldn't save character
}
}
////////////////////////////////////////////////////////////////////////////////
The code above already assumes that the RCSTA, TXSTA, SPBRG, and associated interrupt registers have already been configured.
regards,
Regan.
___________________________
This message was ported from CCS's old forum
Original Post ID: 7916 |
|
|
Tezozomoc Guest
|
Re: F452 RDA interrupt error |
Posted: Thu Oct 17, 2002 4:01 pm |
|
|
I tried this fix but when I am using timer1 and int_rda, int_ext1, int_ext2, it seems to crap out my int_rda... my is INTCON = 0x95 instead of its usual 0xd5.
I am using the latest version of the pch 3.115... its crapping me out.....
Any body else got any other ideas? Please let me know...
Tezo.
:=Hello,
:=
:=Do I have to add Disable_interrupts(global) and Enable_interrupts(global) at the start and end of my IntRDA_handle()?
:=
:=If I don't, sending chars too fast causes a lock up of RS232 comms for a few seconds.
:=
:=I use v3.089 and am porting from 16f877 to 18f452.
:=
:=This is the erratic code:
:=
:=.................... #INT_RDA
:=.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
:=.................... void IntRDA_handle(void)
:=.................... {
:=.................... // Disable_interrupts(global);
:=.................... toRxbuff(Getc());
:=*
:=034A: GOTO 0304
:=034E: MOVFF 01,117
:=0352: MOVFF 117,118
:=0356: GOTO 0322
:=.................... if (Rxispartfull())
:=035A: MOVF xB6,W
:=035C: SUBLW 14
:=035E: BTFSC FD8.0
:=0360: GOTO 0368
:=.................... {
:=.................... // set your handshake here
:=.................... Output_high(RTS);
:=0364: BCF F94.5
:=0366: BSF F8B.5
:=.................... }
:=.................... // Enable_interrupts(global);
:=0368: BCF F9E.5
:=036A: GOTO 0058
:=.................... }
:=
:=
:=This code works: (added dis/enable global interrupts)
:=
:=.................... #INT_RDA
:=.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
:=.................... void IntRDA_handle(void)
:=.................... {
:=.................... Disable_interrupts(global);
:=*
:=034A: BCF FF2.6
:=034C: BCF FF2.7
:=034E: BTFSC FF2.7
:=0350: GOTO 034C
:=.................... toRxbuff(Getc());
:=0354: GOTO 0304
:=0358: MOVFF 01,117
:=035C: MOVFF 117,118
:=0360: GOTO 0322
:=.................... if (Rxispartfull())
:=0364: MOVF xB6,W
:=0366: SUBLW 14
:=0368: BTFSC FD8.0
:=036A: GOTO 0372
:=.................... {
:=.................... // set your handshake here
:=.................... Output_high(RTS);
:=036E: BCF F94.5
:=0370: BSF F8B.5
:=.................... }
:=.................... Enable_interrupts(global);
:=0372: MOVLW C0
:=0374: IORWF FF2,F
:=0376: BCF F9E.5
:=0378: GOTO 0058
:=.................... }
___________________________
This message was ported from CCS's old forum
Original Post ID: 7951 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: F452 RDA interrupt error |
Posted: Thu Oct 17, 2002 5:49 pm |
|
|
I had the same problem with the INTCON. I found that mine was breaking after doing some multiplication and division. As a temporary fix I stored the value of the INTCON register before the math and restored the PEIE and GIE bits afterwards. I then switched compilers to the C18 and noticed a similar with ints. In my case, the problem has only occurred in the ICE2000 and not with an actual chip.
:=I tried this fix but when I am using timer1 and int_rda, int_ext1, int_ext2, it seems to crap out my int_rda... my is INTCON = 0x95 instead of its usual 0xd5.
:=
:=I am using the latest version of the pch 3.115... its crapping me out.....
:=
:=Any body else got any other ideas? Please let me know...
:=Tezo.
:=:=Hello,
:=:=
:=:=Do I have to add Disable_interrupts(global) and Enable_interrupts(global) at the start and end of my IntRDA_handle()?
:=:=
:=:=If I don't, sending chars too fast causes a lock up of RS232 comms for a few seconds.
:=:=
:=:=I use v3.089 and am porting from 16f877 to 18f452.
:=:=
:=:=This is the erratic code:
:=:=
:=:=.................... #INT_RDA
:=:=.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
:=:=.................... void IntRDA_handle(void)
:=:=.................... {
:=:=.................... // Disable_interrupts(global);
:=:=.................... toRxbuff(Getc());
:=:=*
:=:=034A: GOTO 0304
:=:=034E: MOVFF 01,117
:=:=0352: MOVFF 117,118
:=:=0356: GOTO 0322
:=:=.................... if (Rxispartfull())
:=:=035A: MOVF xB6,W
:=:=035C: SUBLW 14
:=:=035E: BTFSC FD8.0
:=:=0360: GOTO 0368
:=:=.................... {
:=:=.................... // set your handshake here
:=:=.................... Output_high(RTS);
:=:=0364: BCF F94.5
:=:=0366: BSF F8B.5
:=:=.................... }
:=:=.................... // Enable_interrupts(global);
:=:=0368: BCF F9E.5
:=:=036A: GOTO 0058
:=:=.................... }
:=:=
:=:=
:=:=This code works: (added dis/enable global interrupts)
:=:=
:=:=.................... #INT_RDA
:=:=.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
:=:=.................... void IntRDA_handle(void)
:=:=.................... {
:=:=.................... Disable_interrupts(global);
:=:=*
:=:=034A: BCF FF2.6
:=:=034C: BCF FF2.7
:=:=034E: BTFSC FF2.7
:=:=0350: GOTO 034C
:=:=.................... toRxbuff(Getc());
:=:=0354: GOTO 0304
:=:=0358: MOVFF 01,117
:=:=035C: MOVFF 117,118
:=:=0360: GOTO 0322
:=:=.................... if (Rxispartfull())
:=:=0364: MOVF xB6,W
:=:=0366: SUBLW 14
:=:=0368: BTFSC FD8.0
:=:=036A: GOTO 0372
:=:=.................... {
:=:=.................... // set your handshake here
:=:=.................... Output_high(RTS);
:=:=036E: BCF F94.5
:=:=0370: BSF F8B.5
:=:=.................... }
:=:=.................... Enable_interrupts(global);
:=:=0372: MOVLW C0
:=:=0374: IORWF FF2,F
:=:=0376: BCF F9E.5
:=:=0378: GOTO 0058
:=:=.................... }
___________________________
This message was ported from CCS's old forum
Original Post ID: 7957 |
|
|
Tezozomoc Guest
|
Re: F452 RDA interrupt error |
Posted: Fri Oct 18, 2002 9:46 am |
|
|
Yes...
I did the same experiment... with the ICE 2000 and an actual chip... it appears that it does not happen with an actual chip. It happens with the emulator only...
I performed some complex triggering with the ice2000.
Experiment one....
Stop the processor if INTCON is written with 0x95... this never triggered...
Experiment two .....
Stop the processor if INTCON reads 0x95.. this event did happened... here follows the trace output....
24F0 5C51 (Forced NOP) 052 00 W 00 00000000 0000A5107B
24F0 5C51 (Forced NOP) --- -- --- -- 00000000 0000A5107C
0018 6E05 MOVWF 0x5 --- -- --- -- 00000000 0000A5107D
001A CFD8 MOVFF --- -- 005 00 00000000 0000A5107E
001C F006 (nop) 0xFD8,0x6 FD8 07 --- -- 00000000 0000A5107F
001E 50E9 MOVF 0xFE9,W --- -- 006 07 00000000 0000A51080
0020 6E07 MOVWF 0x7 FE9 2D W 2D 00000000 0000A51081
0022 50EA MOVF 0xFEA,W --- -- 007 2D 00000000 0000A51082
0024 6E08 MOVWF 0x8 FEA 00 W 00 00000000 0000A51083
0026 50E1 MOVF 0xFE1,W --- -- 008 00 00000000 0000A51084
0028 6E09 MOVWF 0x9 FE1 FF W FF 00000000 0000A51085
002A 50E2 MOVF 0xFE2,W --- -- 009 FF 00000000 0000A51086
002C 6E0A MOVWF 0xA FE2 00 W 00 00000000 0000A51087
002E 50D9 MOVF 0xFD9,W --- -- 00A 00 00000000 0000A51088
0030 6E0B MOVWF 0xB FD9 FF W FF 00000000 0000A51089
0032 50DA MOVF 0xFDA,W --- -- 00B FF 00000000 0000A5108A
0034 6E0C MOVWF 0xC FDA 00 W 00 00000000 0000A5108B
0036 50E0 MOVF 0xFE0,W --- -- 00C 00 00000000 0000A5108C
0038 6E0D MOVWF 0xD FE0 00 W 00 00000000 0000A5108D
003A 0100 MOVLB 0x0 --- -- 00D 00 00000000 0000A5108E
003C 5000 MOVF 0x0,W --- -- --- -- 00000000 0000A5108F
003E 6E0F MOVWF 0xF 000 00 W 00 00000000 0000A51090
0040 5001 MOVF 0x1,W --- -- 00F 00 00000000 0000A51091
0042 6E10 MOVWF 0x10 001 00 W 00 00000000 0000A51092
0044 5002 MOVF 0x2,W --- -- 010 00 00000000 0000A51093
0046 6E11 MOVWF 0x11 002 06 W 06 00000000 0000A51094
0048 5003 MOVF 0x3,W --- -- 011 06 00000000 0000A51095
004A 6E12 MOVWF 0x12 003 00 W 00 00000000 0000A51096
004C 5004 MOVF 0x4,W --- -- 012 00 00000000 0000A51097
004E 6E13 MOVWF 0x13 004 00 W 00 00000000 0000A51098
0050 A09D BTFSS 0xF9D,0x0 --- -- 013 00 00000000 0000A51099
0052 EF2E (Forced NOP) F9D 21 --- -- 00000000 0000A5109A
0054 F000 (nop) 0x000005c --- -- --- -- 00000000 0000A5109B
0056 B09E BTFSC 0xF9E,0x0 --- -- --- -- 00000000 0000A5109C
0058 EF20 (Forced NOP) F9E 30 --- -- 00000000 0000A5109D
005A F001 (nop) timer1_isr --- -- --- -- 00000000 0000A5109E
005C A8F2 BTFSS 0xFF2,0x4 --- -- --- -- 00000000 0000A5109F
005E EF34 (Forced NOP) FF2 95 --- -- 00000000 0000A510A0
0060 F000 (nop) 0x0000068 --- -- --- -- 00000000 0000A510A1
It appears that when the ICE2000 goes into the interrupt handler it reads that INTCON has changed to 0x95 from 0xd5.
the interrupt handler is seen from 24F0 and then going to 0018...
As it is processing the interrupt handler it gets to 005E and then read that 0xFF2(INTCON) is now 0x95....
I have looked through the code to see was changing it and I could not find anything...
Hope you all have better luck...
I am getting ready to battle the MICROCHIP demons... (techsupport)......
Tezo.
:=I had the same problem with the INTCON. I found that mine was breaking after doing some multiplication and division. As a temporary fix I stored the value of the INTCON register before the math and restored the PEIE and GIE bits afterwards. I then switched compilers to the C18 and noticed a similar with ints. In my case, the problem has only occurred in the ICE2000 and not with an actual chip.
:=
:=
:=:=I tried this fix but when I am using timer1 and int_rda, int_ext1, int_ext2, it seems to crap out my int_rda... my is INTCON = 0x95 instead of its usual 0xd5.
:=:=
:=:=I am using the latest version of the pch 3.115... its crapping me out.....
:=:=
:=:=Any body else got any other ideas? Please let me know...
:=:=Tezo.
:=:=:=Hello,
:=:=:=
:=:=:=Do I have to add Disable_interrupts(global) and Enable_interrupts(global) at the start and end of my IntRDA_handle()?
:=:=:=
:=:=:=If I don't, sending chars too fast causes a lock up of RS232 comms for a few seconds.
:=:=:=
:=:=:=I use v3.089 and am porting from 16f877 to 18f452.
:=:=:=
:=:=:=This is the erratic code:
:=:=:=
:=:=:=.................... #INT_RDA
:=:=:=.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
:=:=:=.................... void IntRDA_handle(void)
:=:=:=.................... {
:=:=:=.................... // Disable_interrupts(global);
:=:=:=.................... toRxbuff(Getc());
:=:=:=*
:=:=:=034A: GOTO 0304
:=:=:=034E: MOVFF 01,117
:=:=:=0352: MOVFF 117,118
:=:=:=0356: GOTO 0322
:=:=:=.................... if (Rxispartfull())
:=:=:=035A: MOVF xB6,W
:=:=:=035C: SUBLW 14
:=:=:=035E: BTFSC FD8.0
:=:=:=0360: GOTO 0368
:=:=:=.................... {
:=:=:=.................... // set your handshake here
:=:=:=.................... Output_high(RTS);
:=:=:=0364: BCF F94.5
:=:=:=0366: BSF F8B.5
:=:=:=.................... }
:=:=:=.................... // Enable_interrupts(global);
:=:=:=0368: BCF F9E.5
:=:=:=036A: GOTO 0058
:=:=:=.................... }
:=:=:=
:=:=:=
:=:=:=This code works: (added dis/enable global interrupts)
:=:=:=
:=:=:=.................... #INT_RDA
:=:=:=.................... //#use RS232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, parity=n, bits=8, errors)
:=:=:=.................... void IntRDA_handle(void)
:=:=:=.................... {
:=:=:=.................... Disable_interrupts(global);
:=:=:=*
:=:=:=034A: BCF FF2.6
:=:=:=034C: BCF FF2.7
:=:=:=034E: BTFSC FF2.7
:=:=:=0350: GOTO 034C
:=:=:=.................... toRxbuff(Getc());
:=:=:=0354: GOTO 0304
:=:=:=0358: MOVFF 01,117
:=:=:=035C: MOVFF 117,118
:=:=:=0360: GOTO 0322
:=:=:=.................... if (Rxispartfull())
:=:=:=0364: MOVF xB6,W
:=:=:=0366: SUBLW 14
:=:=:=0368: BTFSC FD8.0
:=:=:=036A: GOTO 0372
:=:=:=.................... {
:=:=:=.................... // set your handshake here
:=:=:=.................... Output_high(RTS);
:=:=:=036E: BCF F94.5
:=:=:=0370: BSF F8B.5
:=:=:=.................... }
:=:=:=.................... Enable_interrupts(global);
:=:=:=0372: MOVLW C0
:=:=:=0374: IORWF FF2,F
:=:=:=0376: BCF F9E.5
:=:=:=0378: GOTO 0058
:=:=:=.................... }
___________________________
This message was ported from CCS's old forum
Original Post ID: 7979 |
|
|
Ron Guest
|
Re: F452 RDA interrupt error |
Posted: Fri Nov 15, 2002 2:36 am |
|
|
R.J.,
Well.. I flagged it as an error to CSS with the content of some of the posts of this forum. No reaction...
Anyway, I upgraded my maintenance for one year and now work with 3.123.
Actually all the previous problems now seem to have disappeared!
I'll stick with 3.123 until it really messes up!
Regards,
Ron
:=:=Hi R.J,
:=:=
:=:=Thanks for the fast reply.
:=:=
:=:=The RDA interrupt is the only interrupt I use!? No priorities set.
:=:=
:=:=Have you got any clue?
:=In which case, I'm afraid the answer is going to lie in what happens in the subroutines. There are significant problems with the current interrupt handler (some of which are still there in the latest 3.115 release...). By disabling interrupts, you are presumably preventing one of these problems from occurring!...
:=Without seeing the code used in the subroutines, it is difficult to know which routine is likely to be causing the problem, but at present the only solution, is to 'bodge round it', either by using the disable interrupt code, or by writing your own interrupt handler...
:=You should 'flag' this as an error to CCS.
:=
:=Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 8960 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|