Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 22 of 22

Thread: compiling problem

  1. #1
    Junior Member
    Join Date
    Jan 2018
    Posts
    10

    compiling problem

    Hallo
    When I am compiling this program I have two errors, can someone help me to fix them ?

    HTML Code:
    
    #define NZEROS 1
    #define NPOLES 1
    #define GAIN   1.324919696e+00
    
    static float xv[NZEROS+1], yv[NPOLES+1];
    int sampleRate=50000;
    //elapsedMicros microCount;
    int microsPerSample =1000000/sampleRate; 
    
    void setup()
    {          
      analogWriteResolution(12);             // max resolution on the output
     analogReadResolution(12);             // same on input
    }
    int myOutput=2048;
    void loop()
    {
      //     analogWrite(A14,myOutput);
            float myInput= analogRead(A0) - 2048;  //512=10 bit DC level adjust!   12 bit = 2048
    
            xv[0] = xv[1]; 
            xv[1] = myInput / GAIN;
            yv[0] = yv[1]; 
            yv[1] =   (xv[0] + xv[1])+ ( -0.5095254495 * yv[0]);     //coefficient is here...
    
             myOutput = 2048 + int(yv[1]); //dc offset + output filter
      
    //  while(microCount<microsPerSample){}     // fill our timing budget
    //  microCount-=microsPerSample;            // keep pace 
    }
    Those two lines are causing the error
    HTML Code:
    //  analogWriteResolution(12);             // max resolution on the output
    //  analogReadResolution(12);             // same on input
    the error with one line disabled

    C:\Users\OWNER\Documents\Arduino\mk_example_3\mk_e xample_3.ino: In function 'void setup()':

    mk_example_3:12: error: 'analogWriteResolution' was not declared in this scope

    analogWriteResolution(12); // max resolution on the output

    ^

    exit status 1
    'analogWriteResolution' was not declared in this scope

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,540
    It compiles for me without error
    for T3.6; A1.8.3; TD 1.39

  3. #3
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    Sorry I forgot, I ma using arduino IDE stm32f103, for arduino due I also have no errors

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,540
    Quote Originally Posted by j23 View Post
    Sorry I forgot, I ma using arduino IDE stm32f103, for arduino due I also have no errors
    maybe you are on the wrong forum?
    Anyhow, check where on your system audio routines are defined and manually add include file

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    16,218
    Maybe then you should with Teensy 3.6 or Arduino Due?

  6. #6
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    I have only stm32 board 72MHz ARM Cortex-M3
    Teensy 3.6 180 MHz ARM Cortex-M4
    Can those differences cause the issue ?
    Last edited by j23; 01-10-2018 at 02:50 PM.

  7. #7
    Moderator KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    3,215
    My guess is that your board does not support that statement, and may or may not support 12 bit analog inputs and outputs.

    But again just a guess. As mentioned by others. This forum is for boards by PJRC (Teensy). You might have better luck if you try asking your question on some other forum that is dedicated to STM32 based boards, preferably one who sells whichever actual board you have.

  8. #8
    Moderator Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,144
    Quote Originally Posted by j23 View Post
    I have only stm32 board
    Nice to meet you on a Teensy forum, though! But you should rather ask on a STM forum...

  9. #9
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    I understand, I am here because I want to adopt Teensy program to my board
    Last edited by j23; 01-10-2018 at 03:03 PM.

  10. #10
    Senior Member
    Join Date
    Dec 2016
    Location
    Canada
    Posts
    826
    you need to look at your STM datasheet and find the proper registers and do it manually if you want to simulate it, you cannot copy a function hardcoded for one product on another, registers are different...

  11. #11
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    may not support 12 bit analog inputs and outputs.
    STM32 microcontrollers embed up to four advanced 12-bit ADCs

  12. #12
    Senior Member
    Join Date
    Dec 2016
    Location
    Canada
    Posts
    826
    my guess is you want support for a product that lacks support for it’s hardware, obviously you purchased the wrong product which is why the support is lacking.

  13. #13
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,540
    Quote Originally Posted by j23 View Post
    I understand, I am here because I want to adopt Teensy program to my board
    Fair enough.
    But it seems that standard Arduino does not implement these two functions.
    analogRead and analogWrite is implemented

    Cannot talk about STM installation

  14. #14
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    16,218
    Quote Originally Posted by j23 View Post
    because I want to adopt Teensy program to my board
    Well, feel free to help yourself to the open source code. It's on github. Or you can run the Teensyduino installer and then find the code in hardware/teensy/avr/cores/teensy3.

    But there is no tech support for using this free software on different hardware.

  15. #15
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    Any advice is helpful, Thanks. This is comparison of 3 boards.
    1. Arduino Due ARM Cortex-M3
    2. STM32F103 devices use the Cortex-M3 core
    3. Teensy 3.6 180 MHz ARM Cortex-M4
    compiling 1 and 3 has no errors, only #2 my has them

    analogWriteResolution - google found it for Teensy 3.6 and for Arduino Due nothing yet for STM32F103 .
    Last edited by j23; 01-10-2018 at 04:05 PM.

  16. #16
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    Quote Originally Posted by Theremingenieur View Post
    Nice to meet you on a Teensy forum, though! But you should rather ask on a STM forum...
    analogWriteResolution - google found it for Teensy 3.6 and for Arduino Due nothing yet for STM32F103 .
    It is time to go there.

  17. #17
    Senior Member manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,259
    If you are trying to use a DAC with analogWrite(), only the STM32F103RET6 has a 12-bit DAC (ye old maple leaflabs devices). The old maple IDE had a separate DAC library (dac_write_channel()) and analogWrite was mapped to pwmWrite. There are forums and github sites where most of the maple IDE has been ported to the Arduino IDE with access to most of the old maple libs.

    https://github.com/rogerclarkmelbour...ino_STM32/wiki

    http://www.stm32duino.com/

    here is a 2013 maple sketch i used to send a sine wave to STM32F103 DAC
    Code:
    // analog out sine wave
    
    #include "dac.h"
    
    float phase = 0.0;
    float twopi = 3.14159 * 2;
    
    void setup() {
      dac_init(DAC,DAC_CH1);
    }
    
    void loop() {
      float val = sin(phase) * 2000.0 + 2050.0;
      dac_write_channel(DAC, 1,(int)val);
      phase = phase + 0.02;
      if (phase >= twopi) phase = 0;
      delayMicroseconds(10);
    }
    Here is a more complicated example that uses TIMER2 to clock a DMA sine table to the DAC (built with maple IDE)
    https://github.com/manitou48/maple/b...ter/dacDMA.pde
    Last edited by manitou; 01-14-2018 at 05:09 PM.

  18. #18
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    why you did that, can't you put this code directly into st32 ?
    Where you have output pin and what is frequency of this generator ?

  19. #19
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    this is what google found.

    I’m trying to use STM32F103C8 with EmonLib. STM32 has 12bits ADC. It would be good to use it.
    I tried to enable it by using setup parameter

    analogReadResolution(12);

    However, it does not fly. I got an error

    'analogReadResolution' was not declared in this scope

    Seems that this command works only for Arduino Due.

  20. #20
    Senior Member manitou's Avatar
    Join Date
    Jan 2013
    Posts
    1,259
    Quote Originally Posted by j23 View Post
    why you did that, can't you put this code directly into st32 ?
    Where you have output pin and what is frequency of this generator ?
    As previously noted, the PJRC forums are for Teensy devices. You need to find some STM32 forums and ask your questions there.
    And give your T3.6 a try, and ask questions here if you have troubles with T3.6

  21. #21
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,540
    Quote Originally Posted by j23 View Post
    However, it does not fly. I got an error
    It should be no surprise that each board has own ser of cores and libraries routines, which may not be compatible to each others.

  22. #22
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    i think i have answer, I going to disable those 2 lines, the ADC will work with default 12 bits. analogWriteResolution(12); - I think the purpose of this function is for easy change the Resolution by changing 12 to different number.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •