Too many instructions

Discussion on projects that are created by users and posted on mikroElektronika website.
Post Reply
Author
Message
carltonb
Posts: 6
Joined: 28 Mar 2014 00:41

Too many instructions

#1 Post by carltonb » 28 Mar 2014 00:47

I've been trying to do a osciloscope with pic 18f4550 and a GLCD module.

i've managed to get pretty far, but i'm having problems with what seems to be too many instructions.

Isolated all my instructions work pretty fine, but when i add some or all of them togheter it simply does not work.

anyone has any idea of what could be happening?

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: Too many instructions

#2 Post by jayanthd » 28 Mar 2014 09:32

Please post the complete code so that the cause for the problem can be found.
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: Too many instructions

#3 Post by petar.timotijevic » 28 Mar 2014 11:54

Hello,

Please see these projects:

Oscilloscope with lcd 128x64
http://www.libstock.com/projects/view/5 ... lcd-128x64

Digital Oscilloscope with lcd 240x128
http://www.libstock.com/projects/view/5 ... cd-240x128


Best regards,
Peter

carltonb
Posts: 6
Joined: 28 Mar 2014 00:41

Re: Too many instructions

#4 Post by carltonb » 28 Mar 2014 19:16

My code:

Code: Select all

char GLCD_DataPort at PORTD;

sbit GLCD_CS1 at RB5_bit;
sbit GLCD_CS2 at RB7_bit;
sbit GLCD_RS  at RB2_bit;
sbit GLCD_RW  at RB3_bit;
sbit GLCD_EN at RB4_bit;
sbit GLCD_RST at RB6_bit;

sbit GLCD_CS1_Direction at TRISB5_bit;
sbit GLCD_CS2_Direction at TRISB7_bit;
sbit GLCD_RS_Direction at TRISB2_bit;
sbit GLCD_RW_Direction at TRISB3_bit;
sbit GLCD_EN_Direction at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB6_bit;

/*
sbit LCD_RS at RE2_bit;
sbit LCD_EN at RE1_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISE2_bit;
sbit LCD_EN_Direction at TRISE1_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
*/


#define botao portb.RB0
 void linhas()
 {
      //Glcd_fill(0);
      Glcd_v_line(0,49,0,1);
      Glcd_v_line(0,49,127,1);
      Glcd_h_line(0,127,0,1);
      Glcd_h_line(0,127,50,1);
  }

 void main()
 {
      float dado[128];
      int var;
      int vbr;
      int vcr;
      int v;
      int x;
      int y;
      int z;
      int tempo;
      unsigned char texto[20];
      unsigned char amp[20];
      unsigned char periodo[20];
      TRISB=0b00000001;                  //Configura a direção do PORTB
      adcon0=0b00000001;
      adcon1=0b00001110;
      adcon2=0b00000110;                 //Configura AD

      delay_ms(2000);                    //Tempo de start-up do display
      tempo=10;

      Glcd_init();
          while (tempo!=0)                                  //loop infinito
       {
             //Glcd_fill(0);
             if (!botao)
                   tempo=tempo * 10;            //Botão está pressionado?
                 if(tempo>1000)
                     tempo=10;
             
             var=0;                                   //reinicializa contadores
             x=0;
             y=0;
             vcr=0;
             while(var<127){                          //atrasa valores no vetor
                   adcon0.go_done=1;                        //Inicializa a conversão
                   while(adcon0.go_done);                   //Aguarda finalizar a conversão
                   dado[var]=((adresh));                      //Lê o conteúdo da conversão
                   dado[var]= dado[var] * 0.1953125;    //conversão para o valor da voltagem considerando espaço de 5 volts em 256 amostras
                   
                   if((int)dado[var]>y)                 //y usado para gravar o valor de amplitude máxima
                   y=(int)(dado[var]);
                   ++var;
                    
                  vdelay_ms(tempo);
               }
               vbr=0;                                           //reinicialização de contador
               Glcd_fill(0);                                    //limpa a tela para iniciar gráfico
               while(vbr<127){                                  //loop de impressão

                  x=(int)(dado[vbr]);                                //imprimir valores *10 para que cada ponto equivala a 0,1Volt
                  Glcd_dot(vbr,x,2);
                  x=0;
                  ++vbr;
                }
                
                while (vcr<100){
                      v=vcr+1;
                      x=vcr+2;
                      if (dado[vcr]==dado[1] && dado[v]==dado[2] && 1==1)
                      z=v;
                      //if (dado[vcr]==dado[2])


                          //  v=v+1;
                          // if(dado[v]==dado[3]){
                           // z=vcr;}


                       //}
                    ++vcr;
                }
                  inttostr(z,periodo);                          //conversão para saber período
                  ltrim(periodo);                                //limpeza do string
                  glcd_write_text(periodo,20,7,2);              //impressão do periodo em segs
                  inttostr(y,amp);                              //conversão para saber a amplitude máxima
                  ltrim(amp);                                   //limpeza so string
                  glcd_write_text(amp,1,7,2);                   //impressão amplitude máxima
                  inttostr(tempo,texto);                        //conversão do sampling rate
                  ltrim(texto);                                 //limpeza do string
                  glcd_write_text(texto,40,7,2);                //impressão do sampling rate
                  linhas();                                     //impressão da grade na tela
        //delay_ms(3000);                                         //Aguarda 3000 ms
       }

 }

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: Too many instructions

#5 Post by jayanthd » 01 Apr 2014 20:12

While(1) loop is missing.
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT

carltonb
Posts: 6
Joined: 28 Mar 2014 00:41

Re: Too many instructions

#6 Post by carltonb » 01 Apr 2014 20:50

tempo is always !=0.
i had it as while(1) before, same problem.

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: Too many instructions

#7 Post by jayanthd » 02 Apr 2014 08:11

Zip and post the complete mikroC project files.
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: Too many instructions

#8 Post by petar.timotijevic » 03 Apr 2014 12:51

Hello,

Please Zip and attach in new post latest version of project files.


Best regards,
Peter

carltonb
Posts: 6
Joined: 28 Mar 2014 00:41

Re: Too many instructions

#9 Post by carltonb » 09 Apr 2014 00:37

attached file.
Attachments
microc2.zip
(85.52 KiB) Downloaded 172 times

jayanthd
Posts: 630
Joined: 08 May 2013 18:31
Location: Bangalore

Re: Too many instructions

#10 Post by jayanthd » 09 Apr 2014 18:17

@carltonb

The code compiled successfully for me. I didn't check your ADCONx settings. ADC result is 10-bit and you have to replace

Code: Select all

dado[var]=((adresh));
by

Code: Select all

dado[var]=(adresh << 8) | adresl;   // if ADC result is right justified.
Zip and post the code which gives "too many initializers" error.

You get that "too many initializers" error if you try something like this.

Code: Select all

unsigned char test[4] = "Hello";   //Hello + '\0' = 6 characters, doesn't fit in 4 bytes
[HW:] EasyPIC v7, mikroProg PIC, AVR, STM32, PSoC, Tiva, 8051
[SW:] mikroC PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroBasic PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
mikroPascal PRO PIC, dsPIC, PIC32, AVR, ARM, 8051
Visual GLCD, Visual TFT

carltonb
Posts: 6
Joined: 28 Mar 2014 00:41

Re: Too many instructions

#11 Post by carltonb » 10 Apr 2014 22:36

Its not an error of "too many identifiers".
Its not a compiling error at all, its just an error at the device itself.
The instructions are only played "half-way" or not at all depending on how many instructions i add to the program.

i have a few pic18f4550 and tested if it was a chip problem but it is not.

carltonb
Posts: 6
Joined: 28 Mar 2014 00:41

Re: Too many instructions

#12 Post by carltonb » 15 Apr 2014 22:21

whenever i get this problem, i noticed that in the hex only has on position 0000 D7FF.
everything else is FFFF.

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: Too many instructions

#13 Post by petar.timotijevic » 16 Apr 2014 03:11

Hello,

What version of compiler you have?

Compiler have proper license?

Try HEX file from attachment.


Best regards,
Peter
Attachments
MyProject.zip
Only HEX file.
(5.5 KiB) Downloaded 149 times

josef2600
Posts: 94
Joined: 01 Jan 2012 03:26

Re: Too many instructions

#14 Post by josef2600 » 18 Apr 2014 06:12

1. 80% you have the license problem ! if you are not registered, register it properly.
2. why you didn't use my oscop project ? petar.timotijevic has told you ! you can see a lot !
3. you better not to use all library's together. its not cool ! think first, then read manual if needed, then choose.
4. you cant use dot for showing on glcd. i had this problem too. its better if you use line instead of dot.
5. i put your code in Proteus with a little changes. check it out and see it is working ! but not very cool ! it needs work.
good luck .
best regards, Josef.
Attachments
microc3.rar
(86.03 KiB) Downloaded 162 times

Post Reply

Return to “User Projects”