Forum: Mikrocontroller und Digitale Elektronik SAMD21-PWM ändert sich nicht


von Ethon (Gast)


Lesenswert?

Hallo,
ich bin gerade dabei von AVRs auf ARMs um zu steigen, dabei habe ich ein 
paar Probleme. Ich habe versucht ein kleines Programm zu schreiben, 
welches ein PWM ausgibt. Das funktioniert auch teilweis, mein Problem 
besteht darin, dass ich das PWM nur durch neu kompilieren und hochladen 
verändern kann und nicht durch eine Schleife in meinem Code. Da ich den 
Fehler leider nicht finden kann wende ich mich an euch. Schon mal danke 
für eure Antworten.
1
#include <asf.h>
2
3
4
struct tcc_module tcc_instance;
5
6
static int8_t configure_tcc()//int8_t dutycycle )
7
{
8
  struct tcc_config config_tcc;
9
  tcc_get_config_defaults(&config_tcc, TCC0);
10
  config_tcc.counter.period = 0xFFFF;                    //16 bit timer
11
  config_tcc.compare.wave_generation =TCC_WAVE_GENERATION_SINGLE_SLOPE_PWM;
12
//   if (dutycycle > 99)
13
//   {
14
//     dutycycle = 100;
15
//   }
16
  config_tcc.compare.match[0] = (0);//0xffff/100)*dutycycle;          // duty cycle 
17
  config_tcc.pins.enable_wave_out_pin[0] = true;
18
  config_tcc.pins.wave_out_pin[0]  =  PIN_PA08E_TCC0_WO0;
19
  config_tcc.pins.wave_out_pin_mux[0] = MUX_PA08E_TCC0_WO0;
20
  tcc_init(&tcc_instance, TCC0, &config_tcc);
21
  tcc_enable(&tcc_instance);
22
  return 0;
23
}
24
25
int main (void)
26
{
27
  system_init();
28
//  int8_t a = 0;
29
  //delay_ms(2500);
30
  while (1)
31
  {
32
    //a=a+25;    
33
    configure_tcc();
34
    tcc_set_compare_value(&tcc_instance,0,0x7fff);
35
//     if (a==100)
36
//     {
37
//       a = 0;
38
//     }
39
    //delay_ms(10);
40
  }
41
}

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.