compiling problem

Status
Not open for further replies.

j23

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

HTML:
#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:
//  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_example_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
 
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
 
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:
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.
 
I understand, I am here because I want to adopt Teensy program to my board
 
Last edited:
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...
 
may not support 12 bit analog inputs and outputs.
STM32 microcontrollers embed up to four advanced 12-bit ADCs
 
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.
 
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
 
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.
 
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:
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/rogerclarkmelbourne/Arduino_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/blob/master/dacDMA.pde
 
Last edited:
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 ?
 
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.
 
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
 
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.
 
Status
Not open for further replies.
Back
Top