On Saturday, August 13, 2022 we will be working on the Adafruit Customer Support Forums. If you visit over the weekend and things are not complete yet, please check back later, https://adafruit.com/forumupdates
0

Generator problem
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Generator problem

by ted456 on Tue Jul 05, 2022 10:06 am

Hi
This generator is working ok when I am using ST Link as upload method , when using a serial method buttons are not working and on display is a number 741 = 741 Hz.
Any idea how to fix it ?
Code: Select all | TOGGLE FULL SIZE
#include <EEPROM.h>

unsigned long amp = 0;

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306_STM32.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

void setup() {

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); 
  display.display();
  display.clearDisplay();
  display.drawPixel(100, 15, WHITE);

  pinMode(PA8, PWM);
  pinMode(PA9, PWM);
  pinMode(PB8, INPUT_PULLUP);
  pinMode(PB9, INPUT_PULLUP);
  TIMER1_BASE->CCER = (1 << 4) | (1 << 0);
  TIMER1_BASE->CCMR1 = (1 << 13) | (1 << 12) | (1 << 5) | (1 << 4);
  TIMER1_BASE->PSC = 0;
  TIMER1_BASE->CCR1 = 0 ;
  TIMER1_BASE->CR1 = 1;
  EEPROM.read(500, (uint16*)&amp);

}

void loop() {
  if (digitalRead(PB8) == 0) {
    amp++;

    EEPROM.write(500, amp);
  }
  if (digitalRead(PB9) == 0) {
    amp--;

    EEPROM.write(500, amp);
  }

  TIMER1_BASE->ARR = amp * 2;
  TIMER1_BASE->CCR2 = amp ;

  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);

  display.setCursor(64, 28);
  display.print(36000000 / amp / 2);
  display.display();

  delay(20);
}

ted456
 
Posts: 18
Joined: Sat Jun 18, 2022 6:13 am

Re: Generator problem

by sj_remington on Tue Jul 05, 2022 12:35 pm

What might the "generator" be?

sj_remington
 
Posts: 456
Joined: Mon Jul 27, 2020 4:51 pm

Please be positive and constructive with your questions and comments.