Kan inte riktigt överge tanken efter att jag fått ett förslag till lösning på Arduino forumet men har inte fått det att fungera riktigt.
Försökt nå den som gav förslaget men inte fått något svar.
Är det någon som har koll på Pico och hur man får detta att rulla? (Använder Arduino IDE):
Kod: Markera allt
//For Earl Philhower core (default board frequency 133 MHz)
// PWM timer config
#define PWM_WRAP 38 // timer period 133 MHz / 38 = 3.5 MHz
pwm_config c_OE = pwm_get_default_config();
pwm_config_set_clkdiv(&c_OE, 1); // prescaler 1
pwm_config_set_wrap(&c_OE, PWM_WRAP-1);
pwm_config_set_output_polarity(&c_OE, false, false); // not invert A & B outputs
// PWM pin config
uint8_t OE_slice_num = pwm_gpio_to_slice_num(pin_OE);
gpio_set_function(pin_OE, GPIO_FUNC_PWM);
pwm_set_gpio_level(pin_OE, PWM_WRAP / 2); // duty 50%
pwm_init(OE_slice_num, &c_OE, true); // start PWM timer
Får följande felmeddelande:
Arduino:1.8.19 (Windows 10), Kort:"Raspberry Pi Pico, 2MB (no FS), 133 MHz, Small (-Os) (standard), Disabled, Disabled, Disabled, Disabled, None, Pico SDK, IPv4 Only"
sketch_oct02a:3:1: error: 'pwm_config' does not name a type; did you mean 'pio_sm_config'?
3 | pwm_config c_OE = pwm_get_default_config();
| ^~~~~~~~~~
| pio_sm_config
sketch_oct02a:4:22: error: expected constructor, destructor, or type conversion before '(' token
4 | pwm_config_set_clkdiv(&c_OE, 1); // prescaler 1
| ^
sketch_oct02a:5:20: error: expected constructor, destructor, or type conversion before '(' token
5 | pwm_config_set_wrap(&c_OE, PWM_WRAP-1);
| ^
sketch_oct02a:6:31: error: expected constructor, destructor, or type conversion before '(' token
6 | pwm_config_set_output_polarity(&c_OE, false, false); // not invert A & B outputs
| ^
sketch_oct02a:8:46: error: 'pin_OE' was not declared in this scope
8 | uint8_t OE_slice_num = pwm_gpio_to_slice_num(pin_OE);
| ^~~~~~
sketch_oct02a:8:24: error: 'pwm_gpio_to_slice_num' was not declared in this scope
8 | uint8_t OE_slice_num = pwm_gpio_to_slice_num(pin_OE);
| ^~~~~~~~~~~~~~~~~~~~~
sketch_oct02a:9:18: error: expected constructor, destructor, or type conversion before '(' token
9 | gpio_set_function(pin_OE, GPIO_FUNC_PWM);
| ^
sketch_oct02a:10:19: error: expected constructor, destructor, or type conversion before '(' token
10 | pwm_set_gpio_level(pin_OE, PWM_WRAP / 2); // duty 50%
| ^
sketch_oct02a:11:9: error: expected constructor, destructor, or type conversion before '(' token
11 | pwm_init(OE_slice_num, &c_OE, true); // start PWM
| ^
exit status 1
'pwm_config' does not name a type; did you mean 'pio_sm_config'?
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Gjorde en version på rent "känn" och som kompilerar och laddar på men inte helt 100% på det jag gjort blev rätt:
Kod: Markera allt
#include "pico/stdlib.h"
#include "hardware/pwm.h"
// PWM timer config
#define PWM_WRAP 38 // timer period 133 MHz / 38 = 3.5 MHz
uint pin_OE = 16;
const int ledPin = 25;
void setup()
{
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH); // Turns on built in LED to show that the PICO is active.
}
void loop()
{
// PWM pin config
gpio_set_function(pin_OE, GPIO_FUNC_PWM);
pwm_config c_OE = pwm_get_default_config();
pwm_config_set_clkdiv(&c_OE, 1); // prescaler 1
pwm_config_set_wrap(&c_OE, PWM_WRAP-1);
pwm_config_set_output_polarity(&c_OE, false, false); // not invert A & B outputs
uint8_t OE_slice_num = pwm_gpio_to_slice_num(pin_OE);
pwm_set_gpio_level(pin_OE, PWM_WRAP / 2); // duty 50%
pwm_init(OE_slice_num, &c_OE, true); // start PWM timer
}