AnsweredAssumed Answered

PIC problem

Question asked by masasi on Oct 27, 2015
Latest reply on Oct 28, 2015 by bpe



I am using a P1012 board, I have configured a global timer on PIC as proposed in I also configure gigabit Ethernet from uboot and I find two possible behaviors on my processor:


- If Ethernet cable is not connected and I configure global timers on the PIC with my init_clock() library function shown below everything works fine.

- If Ethernet cable is connected (sending valid information to microprocessor but the microprocessor is not yet processing those messages) before calling init_clock() library function, once I try to restart the PIC after the global timer configuration, I get the following exception:


NIP: 00000500 XER: 20000000 LR: 00067F14 REGS: 3fa6b748 TRAP: 0700 DAR: 00000000 MSR: 00021200 EE: 0 PR: 0 FP: 0 ME: 1 IR/DR: 00 GPR00: 00067F14 3FA6B838 3FE6BF04 00000000 00000032 00000040 3FFC7E58 00000000 GPR08: 000F65C0 00000020 00000020 3FA6B838 44022084 82C4195D 3FFBB4E8 00000000 GPR16: 3FFF064C 00000000 3FE73348 00497A38 00400000 00000000 00000000 00000001 GPR24: 3FFDD310 3FF78EB4 00000000 3FE7335C 00000000 3FE7335C 3FFC3C18 3FA6B838 ** Illegal Instruction ** Call backtrace: 00067F14 00067A08 3FF78F1C 3FF799D8 3FF79B1C 3FF8433C 3FF89E70 3FF8A4D8 3FF897D8 3FF8E254 3FF77C88 3FF7164C Program Check Exception ### ERROR ### Please RESET the board ###


I believe this is due to the interrupts the etsec and MDIO are sending to the PIC because the Ethernet messages are not being treated yet, is this correct? I have not masked any etsec interruption(IMASK set to 0) and the DISR register is set to 1s in order to avoid sending interrupts to the PIC.TEMASK and PEMASK are also set to 0.


I would like to know how can I disable all kind of interruptions from the etsec so I do not get this exception.

Thanks in advance!




void init_clock(void) {   

     ccsr_pic_t *pic = (ccsr_pic_t *)0xFF740000;

     unsigned int *p;   

     unsigned int il,m,n;   

     int *pic_gcr;   

     int *pic_tcr0;   

     int *pic_gtvpr;   

     int *pic_ctpr;   

     int *pic_gtbcr;   

     int *maccfg1;       



     /* Disable Transmit and Receive */   

     *maccfg1= ~(0x00000004 | 0x00000001);      

     //Reset PIC   

      *(unsigned int *)&pic->gcr=0x80000000;       

     __asm__("wrteei 0\n");   


     // mask all external interrupts

     p=(unsigned int *)&pic->eivpr0;

     for (il=0; il<12; il++) {

           *p=0x80000000+il; p +=8;


     *(unsigned int *)&pic->ctpr=0x0;

     // the highest priority for processor tasks

     *(unsigned int *)&pic->ctpr0=0x0;   

     // set mixed mode.

     *(unsigned int *)&pic->gcr=0x20000000;

     // Interrupts are handled by the normal priority and delivery mechanisms of the PIC.   

     // clear all spurious interrupts


     // read number of interrupts

     m >>=16;

     m &=0x7FF;

     for(il=m;il>0;il--) {


          if (n!=0xFFFF) {







          if (n!=0xFFFF) {




     //Init Global Timer

     //Configure clock source   



     //Set priority and vector of GTVPR   



     //Set GCR[M] to be mixed mode   


     //Set base counts   



     //Enable counting   


     install_handler (timer_handler);   

      __asm__("wrteei 1\n");