Portenta breakout analog pins

Hi everyone,
I am struggling with the DAC on the Portenta H7, which I have placed on a breakout board. The goal of my project is to produce a sinewave with a stepwise growing offset, but so far I still work on smaller problems:

  1. The code below should just give me an output of 10mV for 1 second, then 20mV for 1 second and so on. If I specify A6 as output pin, it works more or less, but the voltage only goes up to 2.2V and then stops there. If I define A7 as output pin, I get continuously 3.3V and no steps at all. For pin A5 or A0, the red led starts flashing during the upload... Why?
#define MAX_VOLTAGE 3.3   
#define STEP_VOLTAGE 0.01  
#define DAC_RESOLUTION 4095

void setup() {
    Serial.begin(9600);
}

void loop() {
    for (float voltage = STEP_VOLTAGE; voltage <= MAX_VOLTAGE; voltage += STEP_VOLTAGE) {
        uint16_t dacValue = (uint16_t)((voltage / MAX_VOLTAGE) * DAC_RESOLUTION); 
        analogWrite(A6, dacValue);
        
        Serial.print("Ausgabe: ");
        Serial.print(voltage * 1000);
        Serial.println(" mV");
        delay(1000);
    }
}


According to the documentation, pin A0, A5-A7 should all work, right?

  1. I tried to make a sinewave output with a frequency of 3187Hz (see code below). This works for SAMPLES=44, but if I set a higher value for samples, then it still works, but my frequency is >3187Hz. Why??
#include <Arduino_AdvancedAnalog.h>

#define SAMPLE_RATE 3187
#define SAMPLES 44
#define PI 3.14159265358979323846

AdvancedDAC dac1(A6); 
uint16_t SAMPLES_BUFFER[SAMPLES];

void generate_waveform() {
    for (int i = 0; i < SAMPLES; i++) {
        SAMPLES_BUFFER[i] = (sin(2 * PI * (i / (float) SAMPLES)) * 2047) + 2047; 
        
    }
}

void setup() {
    Serial.begin(115200);
    generate_waveform();

    if (!dac1.begin(AN_RESOLUTION_12, SAMPLE_RATE * SAMPLES, SAMPLES, 32)) {
        Serial.println("Failed to start DAC!");
        while (1);
    }

    Serial.println("DAC gestartet mit Sinusfrequenz 3187 Hz auf Pin A6.");
}

void loop() {
    if (dac1.available()) {
        SampleBuffer buf = dac1.dequeue();

        for (size_t i = 0; i < buf.size(); i++) {
            buf[i] = SAMPLES_BUFFER[i];
        }

        dac1.write(buf);
    }
}

I would be very thankful for some help!