EmbDev.net

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


von Víctor (Guest)


Rate this post
0 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
}

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.