Sonsivri

Electronics => Pic C Languages => Topic started by: jlian168 on April 01, 2010, 08:58:51 08:58



Title: Why MikroC's simulator doesn't work?
Post by: jlian168 on April 01, 2010, 08:58:51 08:58
Dear all:
I'm write a simply program to test MikroC for PIC.
I only open timer 1 to use,Then i set a breakpoint in the interrupt,
But the interrupt never be break,I don't why?
Can anyone tell me why?
//************************************************
void interrupt(void) {
     if(TMR1IE_bit)
     {
               if(TMR1IF_bit)
               {
                         TMR1IF_bit=0;
                         TMR1H=(65536-time1_base)/256;
                         TMR1L=(65536-time1_base)%256;

                         if(!(--A))
                                          A=10;
               }
     }
}
//
void main() {
     initial();
     while(1)
     {
             CLRWDT();
             r_cnt++;
     }
}
//
void initial(void) {
     PORTA=0;
     PORTC=0;
     TMR1H=(65536-time1_base)/256;
     TMR1L=(65536-time1_base)%256;
     T1CON=5;
     CMCON0=7;
     OSCCON=0x67;
     OPTION_REG=0xcf;
     ANSEL=0;
     WPUA=0;
     TRISA=0x38;
     TRISC=0x30;
     //TMR1IE_bit=1;
     PIE1=0x01;
     FSR=0x20;
clr_ram:
     INDF=0;
     if(FSR<0x60)
     {
                 FSR++;
                 goto clr_ram;
     }
     A=10;
     PEIE_bit1;
     GIE_bit=1;
/*****************************************************
Thank ypu very much.


Title: Re: Why MikroC's simulator doesn't work?
Post by: piccolo on April 01, 2010, 11:43:00 11:43
Interrupt is not automatic in debug mode.
You must manually enter in interrupt function with the key F2.

Or with menu -> Run -> Jump to interrupt.


Title: Re: Why MikroC's simulator doesn't work?
Post by: sam_des on April 01, 2010, 05:28:49 17:28
Hi,

mikroC's debugger is just an "Instruction Set Simulator". That's why it can execute the individual instructions of PIC core but it has no understanding of PIC's peripherals like the Timer you are trying to simulate.

Better use MPLAB or ISIS or even better switch to some other sensible compiler such as cc5x/hi-tech/iar  :P

But AFAIK mikroC doesn't output cod/coff/elf or any other files that can be loaded into ISIS or MPLAB. If I remember correctly there was a tool that can convert mikroC files to coff. Search forum or net, you'll get it, but don't how much it works :-\

Hope that helps,
regards,
sam_des


Title: Re: Why MikroC's simulator doesn't work?
Post by: tAhm1D on April 01, 2010, 08:06:20 20:06
But AFAIK mikroC doesn't output cod/coff/elf or any other files that can be loaded into ISIS or MPLAB.

mikroC does output coff files. Just get the new one.


Title: Re: Why MikroC's simulator doesn't work?
Post by: FlvAnm on April 02, 2010, 09:35:40 09:35
In mikroC PRO for PIC you can generate coff file to debug C, for example in MPLAB. To generate coff file : Tools -> Opitons -> Output Settings and check Generate COFF file.

Flvanm