From: SourceForge.net <no...@so...> - 2009-09-09 20:37:11
|
Bugs item #2840515, was opened at 2009-08-19 20:42 Message generated for change (Settings changed) made by galzsolt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2840515&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: pic14 target Group: known bugs >Status: Closed Resolution: None Priority: 5 Private: No Submitted By: Gál Zsolt (galzsolt) Assigned to: Raphael Neider (tecodev) Summary: array index handling in interrupt Initial Comment: I tried to make test program for my mTouch panel which is described on the Microchip web page. Unfortunately I did not found any demo program on this page, only some snippets in pdf documents. So I started to write a program in C. During this process I had to realise, that there is something wrong around the array index. When I use indexed array both in interrupt routine and main program, the data in the array become confused. I made a solution which is very unconfortable. You can check it. This program try to display the actual reading of the sensor the maximum and the minimum values on a serial LCD panel. I am using sdcc in PikLab. SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.9.0 #5416 (Mar 22 2009) (UNIX) gpasm-0.13.7 beta ---------------------------------------------------------------------- Comment By: Raphael Neider (tecodev) Date: 2009-08-28 01:02 Message: We had a similar discussion on the sdcc-user list as "[Sdcc-user] Problem with interrupts." starting on 2009-05-05 (see mailing list archive at https://sourceforge.net/mailarchive/forum.php?thread_name=b321594e0905120713w1a8b91e6j1affe45fcadda29a%40mail.gmail.com&forum_name=sdcc-user ). On 2009-05-10 and 2009-05-11 I proposed workarounds, both of which are ugly but should work and are also pretty close to what the compiler would have to generate -- unfortunately the overhead is quite noticeable. The problem is that the PIC14 port does not save the pseudo stack locations (STKxx) during interrupts -- but does not hesitate to destroy them on the first function call from inside the interrupt handler. The workaround is to copy all ~16 pseudo stack locations to a "safe place"(TM) on interrupt handler entry and restore them at its exit. Sorry for the inconvenience. Best regards Raphael ---------------------------------------------------------------------- Comment By: Frieder Ferlemann (frief) Date: 2009-08-27 22:45 Message: Hi Gál, are you using an unsigned char or an unsigned integer index into the table / how large is the table / is the procedure that you have removed a function call / is the data pointed to 1/2/4 byte wide / could you provide a snippet of your source code? ---------------------------------------------------------------------- Comment By: Gál Zsolt (galzsolt) Date: 2009-08-27 09:49 Message: It is missing in my reporting that this problem is on a PIC14 device. So I don't know is this problem exist on other microcontroller or not. I am using only PIC14 devices like PIC16F628, PIC16F690, PIC16F887. I made some modification in the program structure to avoid using array in the interrupt routine. I removed all array variable and multiply / divide procedure. The result is a good working program. So I suggest everybody who has a plan to use array / multiply / divide procedure not to put into the interrupt service routine. It is better using a FLAG in the interrupt routine and watch this FLAG in a normal function. In case this FLAG is set or not make a deal to do the complex tasks. Analise the assembly code you can find the part which cause the problem. If you use any multiply operation the compiler put the STK00 STK01 STK02 variables in the procedure. When you realize it is happen with your interrupt routine you should make modification on it, because you will have a good chance for a tricky problem at running your program on a PIC. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2840515&group_id=599 |