Author Topic: Atmel ATSAM4S SAM4S-EK2 Dev kit F_CPU issues (and other questions)  (Read 1766 times)

0 Members and 1 Guest are viewing this topic.

Offline CM800Topic starter

  • Frequent Contributor
  • **
  • Posts: 882
  • Country: 00
After finally sorting myself out an Atmel-ICE programmer and a suitable breakout board to allow me to connect to my SAM4S-EK2 dev board, I have finally managed, after a few days of on-off searching for tutorials that will help me with it... managed to turn an LED on!

Now, shortly after this, I followed the tutorial further to get it to blink, however I noticed a problem, the LED seems to blink very -very- slowly compared to what it was meant to.

using the delay library and led library in Atmel's ASF setup I formed this program together:

Code: [Select]
#include <asf.h>
#include "led.h"
#include "delay.h"

int main (void)
{
/* Insert system clock initialization code here (sysclk_init()). */

board_init();
LED_On(LED1_GPIO);
/* Insert application code here, after the board has been initialized. */
while(1)
{
delay_ms(1000);
LED_Toggle(LED1_GPIO);
}


}

this seems to make it blink at an exceedingly slow rate (on / off for over 30 seconds each?)
if I change the time to 5 I can get it to blink on and off about 2-3 times per second instead, however I cannot seem to work out how to set the frequency correctly (or why it is detecting the incorrect frequency setting considering the IDE knows what board I am running and has some sort of auto-detect code in there that is obviously not working...


Now, does anyone know how I can resolve this issue?

I would also really appreciate any suggested tutorials or readings for continuing on with this, especially in the area of PWM.


Thanks in advance!
« Last Edit: November 01, 2015, 11:28:42 pm by TCWilliamson »
 

Offline CM800Topic starter

  • Frequent Contributor
  • **
  • Posts: 882
  • Country: 00
Re: Atmel ATSAM4S SAM4S-EK2 Dev kit F_CPU issues (and other questions)
« Reply #1 on: November 01, 2015, 11:25:21 pm »
Alright, amazingly I managed to sort out the clock issue (randomly reading through someone else's unrelated code I saw someone running 'sysclk_init();' in it and decided to try adding that to my code.
It fixed it.

Such is life, I spend hours looking around on how to fix it, and half-hour after posting the issue to a forum I near instantly find the solution myself.  :-DD
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf