EmbDev.net

Forum: ARM programming with GCC/GNU tools PWM on SAMD21


von Víctor (Guest)


Rate this post
useful
not useful
So I was trying this code I got right off a book but changing the pin 
where I should have the PWM signal output... but it is not working... 
any guesses why?... PD: I can't do debugging because I have a strange 
error on executing the ELF file.

Wrote this code on and did the programming on atmel studio 7 with the 
atmel - ice.
1
#include "sam.h"
2
3
unsigned char* ARRAY_PORT_PINCFG0 = (unsigned char*)&REG_PORT_PINCFG0;
4
unsigned char* ARRAY_PORT_PMUX0 = (unsigned char*)&REG_PORT_PMUX0;
5
6
int main(void)
7
{
8
  
9
  REG_GCLK_CLKCTRL = 0x401A; //TCC0 para PWM en GCLK0
10
    REG_PM_APBCMASK |= 0x00000100; //Enable TCC0, es la funcion F para el pin PA17
11
  REG_TCC0_CTRLA = 1; //Reset al registro
12
13
  while(REG_TCC0_CTRLA & 1){} //Esperar hasta sincronizar
14
  
15
  REG_TCC0_WAVE = 2; // Modo PWM normal
16
  REG_TCC0_PER = 16666-1;
17
  REG_TCC0_CC0 = 5555-1;
18
  REG_TCC0_CTRLA |= 2;
19
  
20
  ARRAY_PORT_PINCFG0[17] |= 1; //Activa el multiplexor a perifericos
21
  ARRAY_PORT_PMUX0[8] = (0x5<<4);
22
  
23
  while (1) 
24
    {
25
  }
26
}

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.