Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] GENERIC mx250/220 interrrupt problems
04-07-2012, 09:07 AM, (This post was last modified: 05-07-2012, 09:50 AM by gagabi.)
#1
[SOLVED] GENERIC mx250/220 interrrupt problems
IDE: 3x.r483 (linux)
Board : GENERIC32MX220F032B/GENERIC32MX250F128B
There are NO compile time errors.


When I try to use program modul, that uses interrupt, the board stops.

For example:
-If I include "millis()" anywhere in the program. It stops immeditely ( or at the 1st interrupt?).
-If the serial line is used ( I have to enable pins by hand because it missing from io.c ) everything works . But when the 1st character is received (handled by interrupt) the board stops.
PHP Code:
void setup()
{
 
Serial.init(9600);  
 
System.unlock();
 
CFGCONbits.IOLOCK=0;
 
CFGCONbits.PMDLOCK=0;
 
U1RXRbits.U1RXR=2;             //UART1 RX -> RA4 (pin11)
 
RPB4Rbits.RPB4R=1;             // UART1 TX -> RPB4 (pin12)
 
CFGCONbits.IOLOCK=1;
 
CFGCONbits.PMDLOCK=1;
 
// IEC1bits.U1RXIE=0;    // Disable interrupt for testing
 
System.lock();
 
pinMode(13,OUTPUT);
 
CDC.getKey();
 
printconfig("U1RXR=",U1RXR);
 
printconfig("RPB4R=",RPB4R);
 
printconfig("U1MODE=",U1MODE);
 
printconfig("U1STA=",U1STA);
 
printconfig("U1BRG=",U1BRG);
 }


void loop()
{
 
u8 i,j;
 
i=CDC.read(buffer);
 
j=0;
 while( 
){
      
CDC.write(c=buffer[j]);  
      
i--;
      
j++;
      
toggle(13);
 }


Yes now I do not use any of Serial commands, except of Serial.init(). It is only a test. But if I send a character to serial line ( receive from the view of board) , then the program stops. If I disable the UART1 receive interrupt, the program does not stops.

I tried to write new serial routine for myself without using interrupt, it worked, but there was a lot of overrun errors, because the long latency of the user program, so I need to use interrupt.

I would be happy if i could use millis() function too.

There is a little problem whith CDC routines too. In the example above some characters are dissapears. But if I comment out the line "USB_Service();" from the CDCgets in __cdc.c then it works fine . If I put that line to CDCgetkey's while :
while(!CDCgets(buffer))USB_service();
Then the CDC.getkey() is working fine too.

Thank You for helping

Gábor
ps.: Sorry about my english.
Reply
04-07-2012, 09:17 AM,
#2
RE: GENERIC mx250/220 interrrupt problems
Do you know the problem must be software?

(Because the chips are known to work.)

So, you need to find what you've changed wrongly and/or what needs changing but you have not (yet) changed.

John
Reply
04-07-2012, 10:10 AM,
#3
RE: GENERIC mx250/220 interrrupt problems
(04-07-2012, 09:17 AM)pingotg Wrote: Do you know the problem must be software?

(Because the chips are known to work.)

So, you need to find what you've changed wrongly and/or what needs changing but you have not (yet) changed.

John

Thanks for fast reply.

The board is very simple, similar to DIY, nothing extra, just the power suply is changed . . . I tried it with pic32mx220F032B (2 pcs.) and with pic32mx250F128B (I hoped the probblem is with small RAM or FLASH, but not).

If I used both of chip without interrupt, then I could receive data from serial line. I wrote a program which read from cdc and writes it to serial, and reads from serial and writes it to cdc. It worked, but if long serial message arrived, then the chip internal buffer overflowed. That is why I have to use interupt driven solution.

I deleted the full pinguino and made a new svn checkout. I wrote the program without any modification in the original libraries. But the problem is still there. After it I modified the __CDC.c program. And found the solution of dissapering characters.


So I think, I did not change anything that kills interrupt routine.
And I don't know what to change that I didn't (yet).


millis() is working with PIC32 pinguino OTG., But I want use mx250/220
With millis() I was wrong, there was a problem in my program.
But the problem is still exist. What I was wrong: I assumed that millis is changeing and my program went in an endless loop.
But with 250and 220 millis() is allways 0.

I tried the following simple program with PIC32 pinguino OTG and pic32mx250F128B.
OTG is counting, mx250 is allways 0.


PHP Code:
void setup()
{                
    
// initialize the digital pin 13 as an output.
    
pinMode(13OUTPUT);     
}

void loop()
{
    
toggle(13);            // alternate ON and OFF
    
delay(100);        // wait for a second
  
CDC.printf("%d\n",millis());


I think maybe millis()'s interrupt is disabled (?).
My problem is with serial still exists.
Thanks
Gábor ps.

From the original post there is missing the declaration of printconfig:
printconfig is similar to
CDC.printf("%s%08X\n",description,value);
But I don't like to use printf . . .

PHP Code:
void printconfig(charstringu32 valtozo){
    
    
u8 tohex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
    
CDC.puts(string,strlen(string));
    
CDC.write(tohex[(valtozo>>28)&15]);
    
CDC.write(tohex[(valtozo>>24)&15]);
    
CDC.write(tohex[(valtozo>>20)&15]);
    
CDC.write(tohex[(valtozo>>16)&15]);
    
CDC.write(tohex[(valtozo>>12)&15]);
    
CDC.write(tohex[(valtozo>>8)&15]);
    
CDC.write(tohex[(valtozo>>4)&15]);
    
CDC.write(tohex[valtozo&15]);
    
CDC.write('\n');
        } 
Reply
04-07-2012, 10:44 AM,
#4
RE: GENERIC mx250/220 interrrupt problems
Regarding interrupts, please also have a look at the rather longish thread "Pic32 Interrupts" in "Syntax & Programs".

Which bootloader are you running?

/M
Reply
04-07-2012, 05:31 PM,
#5
RE: GENERIC mx250/220 interrrupt problems
(04-07-2012, 10:44 AM)MarSch Wrote: Regarding interrupts, please also have a look at the rather longish thread "Pic32 Interrupts" in "Syntax & Programs".

Which bootloader are you running?

/M

Thank You for helping.
Before I opened this thread I have searched and read the forum about it, and I have found the thread you suggest for me. I tried the IntConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
But nothing has changed. Because I didn't want to write interrupt handler, and I didn't wanted to use external interrupt, and I used ide 3.x not the 2.x , I didn't read this thread deeply, but now I will dive in it. :-)


mx250 has bootloader from Pinguino32-DIY.tar.lzma:
http://code.google.com/p/pinguino32/downloads/
mx220 from pinguino/extra/bootloaders/32bit/PIC32-Pinguino_HIDBoot_M220.hex at ~jun 1-2
OTG has original bootloader. I don't know which version.

Can I found somewhere better one's?


Gábor
Reply
05-07-2012, 09:19 AM, (This post was last modified: 05-07-2012, 10:17 AM by gagabi.)
#6
RE: GENERIC mx250/220 interrrupt problems
I checked "millis.c"

It is not Generic32mx250/220 compatible. (f.e. it does not enable interrupt, neither start timer).

Because 32mx220 and 32mx250 are same processor exept the memory and flash size, and PINGUINO_220 has same processor, but different package (and fewer pins . . .)
I modified millis.c :
replaced
#ifdef PIC32_PINGUINO_220
with
#if defined(PIC32_PINGUINO_220)||defined(GENERIC32MX250F128)||defined(GENERIC32MX220F032)

And checked in Microchips documentation, if it has meaning or not.
Yes, it should work.
Now, my blinky test program (which writes millis() in every 100ms see
in previos post) works with OTG but stops with 32mx250.

millis.c is so simple! it just programs the timer, enables interrupt, and in interrupt routine increases _millis.

If I disable interrupt in milis.c then the program runs , but of course millis() are always 0.



So there will be something general problem with interrupts in GENERIC32MX250/220 boards.

I studied the "pic32 interrupts" thread. The interrupt routines there are using the same methode as serial , and millis does. But the interrupt handler is filled and inserted at the p32/lkr/GENERIC32MX250F128/ISRwrapper.S

Gábor

I have found that interrupt.c was not completly rewriten for GENERIC220/250 boards.

in the routine IntConfigureSystem()
I had to replace the
#ifdef PIC32_PINGUINO_220
with
#if defined(PIC32_PINGUINO_220)||defined(GENERIC32MX250F128)||defined(GENERIC32MX220​F032)


And now Interrupts are working!
I think, it is SOLVED now.

Thanks for everybody for helps.
Gábor
ps.:

How can I ask developers to include theese in the code? And review all other sources where pinguino_220 is handled differently than generic_250/220 boards?

Reply
05-07-2012, 10:47 PM,
#7
RE: [SOLVED] GENERIC mx250/220 interrrupt problems
Hi Gabor

Many thanks for your fix in the files.
I updated millis.c and interrupt.c and committed a new revision ( 484 ).

Now everything should be OK.

Thanks
JP
Reply
03-12-2012, 09:28 PM,
#8
RE: [SOLVED] GENERIC mx250/220 interrrupt problems
Hi,

I hope this is the right place to report this.
I have downloaded X.3 revision 639 using

svn checkout http://pinguino32.googlecode.com/svn/trunk/

Regarding the fix in this thread, the file millis.c seems to have some non-printing characters in the #defines

#if defined(PIC32_PINGUINO_220)||defined(GENERIC32MX250F128)||defined(GENERIC32MX220<Extra characters here: 0xE2808B>€‹F032)

This prevents the file from compiling with an error about missing ')'
The non-printing characters are not visible in the IDE but can be seen if the file is viewed in a hex editor or the SciTE text editor.

With the extra non-printing characters removed everything is fine.

OS is linux. I've tried checking out the files on a 32bit Ubuntu 12.04 system and 64bit Mint 13 with the same result. I haven't checked any earlier revisions.
Reply
06-12-2012, 12:04 PM,
#9
RE: [SOLVED] GENERIC mx250/220 interrrupt problems
Hi,
Actually x.3 development has been stopped at rev. 553
The new development version is x.4 (rev. 640) where the bug you mentionned has been fixed some time ago. Try to download this version using :
svn checkout http://pinguino32.googlecode.com/svn/branches/
Anyway, thank you to help us.
Régis

(03-12-2012, 09:28 PM)HarryE Wrote: Hi,

I hope this is the right place to report this.
I have downloaded X.3 revision 639 using

svn checkout http://pinguino32.googlecode.com/svn/trunk/

Regarding the fix in this thread, the file millis.c seems to have some non-printing characters in the #defines

#if defined(PIC32_PINGUINO_220)||defined(GENERIC32MX250F128)||defined(GENERIC32MX220<Extra characters here: 0xE2808B>€‹F032)

This prevents the file from compiling with an error about missing ')'
The non-printing characters are not visible in the IDE but can be seen if the file is viewed in a hex editor or the SciTE text editor.

With the extra non-printing characters removed everything is fine.

OS is linux. I've tried checking out the files on a 32bit Ubuntu 12.04 system and 64bit Mint 13 with the same result. I haven't checked any earlier revisions.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)