Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3847

General • Re: RP2040 Read Timer

$
0
0

Code:

uint counter_slice;// Initialise frequency pulse countervoid freq_counter_init(int pin) {    assert(pwm_gpio_to_channel(pin) == PWM_CHAN_B);    counter_slice = pwm_gpio_to_slice_num(pin);     gpio_set_function(pin, GPIO_FUNC_PWM);    pwm_config cfg = pwm_get_default_config();    pwm_config_set_clkdiv_mode(&cfg, PWM_DIV_B_RISING);    pwm_config_set_clkdiv(&cfg, 1);    pwm_init(counter_slice, &cfg, false);}//rem---------------------------------------------------unsigned long M;//--------void setup(){Serial.begin(115200);}//--------void loop(){M=micros();Serial.print(" M= ");Serial.println(M);delay(1000);}
Error:

In file included from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/tools/pqt-gcc/4.0.1-8ec9d6f/arm-none-eabi/include/c++/14.2.0/cassert:44,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/pico-sdk/src/common/pico_base_headers/include/pico/assert.h:14,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/pico-sdk/src/common/pico_base_headers/include/pico/types.h:12,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/pico-sdk/src/common/pico_base_headers/include/pico.h:26,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/pico-sdk/src/rp2_common/pico_lwip/include/arch/cc.h:88,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/pico-sdk/lib/lwip/src/include/lwip/arch.h:48,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/pico-sdk/lib/lwip/src/include/lwip/debug.h:40,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/pico-sdk/lib/lwip/src/include/lwip/opt.h:52,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/pico-sdk/lib/lwip/src/include/lwip/init.h:40,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/ArduinoCore-API/api/IPAddress.h:26,
from C:/Users/Aleksandr/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/4.1.1/ArduinoCore-API/api/ArduinoAPI.h:30,
from C:\Users\Aleksandr\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\4.1.1\cores\rp2040/api/ArduinoAPI.h:2,
from C:\Users\Aleksandr\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\4.1.1\cores\rp2040/Arduino.h:28,
from C:\Users\Aleksandr\AppData\Local\Temp\arduino\sketches\3EF4A68F49D6E0F25A924A0F38F573DD\sketch\RP2040_2_Core_2024_10_22.ino.cpp:1:
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino: In function 'void freq_counter_init(int)':
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino:5:12: error: 'pwm_gpio_to_channel' was not declared in this scope
5 | Serial.begin(115200);
| ^~~~~~~~~~
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino:5:40: error: 'PWM_CHAN_B' was not declared in this scope
5 | Serial.begin(115200);
| ^
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino:6:21: error: 'pwm_gpio_to_slice_num' was not declared in this scope
6 | }
| ^
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino:9:5: error: 'pwm_config' was not declared in this scope; did you mean 'pio_sm_config'?
9 | {
| ^
| pio_sm_config
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino:10:33: error: 'cfg' was not declared in this scope
10 | M=micros();
| ^
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino:10:38: error: 'PWM_DIV_B_RISING' was not declared in this scope
10 | M=micros();
| ^
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino:10:5: error: 'pwm_config_set_clkdiv_mode' was not declared in this scope; did you mean 'sm_config_set_clkdiv'?
10 | M=micros();
| ^~~~~~~
| sm_config_set_clkdiv
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino:11:5: error: 'pwm_config_set_clkdiv' was not declared in this scope; did you mean 'sm_config_set_clkdiv'?
11 | Serial.print(" M= ");Serial.println(M);delay(1000);
| ^~~~~~~~~~~~~~~~~~~~~
| sm_config_set_clkdiv
C:\Users\Aleksandr\Documents\Arduino\RP2040_2_Core_2024_10_22\RP2040_2_Core_2024_10_22.ino:12:5: error: 'pwm_init' was not declared in this scope; did you mean 'sem_init'?
12 | }
| ^
| sem_init

exit status 1

Compilation error: 'pwm_gpio_to_channel' was not declared in this scope

Statistics: Posted by Aleks_2024 — Sat Oct 19, 2024 10:48 am



Viewing all articles
Browse latest Browse all 3847

Trending Articles