Author Topic: First LED Blinky not working on SAMD10D14  (Read 1475 times)

0 Members and 1 Guest are viewing this topic.

Offline n4alpacaTopic starter

  • Newbie
  • Posts: 9
  • Country: us
First LED Blinky not working on SAMD10D14
« on: October 31, 2017, 04:01:18 am »
Hello, This will hopefully be the first first microcontroller I get to blink an LED (with you guys' help). I'll start by describing the setup:

I have a broken out and bread boarded SAMD10D14 (20 pin SOIC). I have a 47uF electrolytic capacitor on my Vin in addition to an 0.1uF ceramic capactior near the Vin Pin on the breakout board.
The voltage sits at about 3.05V via a voltage divider powered by a 5V usb charger. The voltage divider is made of something like a 47 and 68 ohm resistor so there is sufficient current for sure (100mA) as the led only requires at minimum something like 5. I'm also sure it works because it's been tested independently.
I'm connecting to the uC with a J-link edu via SWD with 100k pullups on SWCLK, SWDIO and nRST. I can connect and see the registers just fine.
I'm using Segger embedded studios.
My LED is connected to a 330 ohm resistor and the pin PA05.
There aren't any errors, the pin simply doesn't light up as it's supposed to. I check the registers and the value I wrote to them is there.

I have no idea what is happening. My code and a picture of the IDE:



Thanks for looking!
« Last Edit: October 31, 2017, 04:05:51 am by n4alpaca »
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: First LED Blinky not working on SAMD10D14
« Reply #1 on: October 31, 2017, 04:19:09 am »
Where is the other side of that LED?

And use CMSIS header files. I have not checked if your register definitions are correct, but the code looks correct, provided that SEGGER startup does not do something silly.

Also, try to define those registers as "volatile unsigned long".
Alex
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: First LED Blinky not working on SAMD10D14
« Reply #2 on: October 31, 2017, 04:22:30 am »
Actually, you are toggling PA4.

Do things like REG = (1<<5); and let compiler shift things for you.
Alex
 

Offline n4alpacaTopic starter

  • Newbie
  • Posts: 9
  • Country: us
Re: First LED Blinky not working on SAMD10D14
« Reply #3 on: October 31, 2017, 03:28:25 pm »
Thanks so much! The LED turns on now. I haven't used CMSIS yet, but looking into the include files, it seems as though I would use that instead of my register definitions? I tried using ASF before and I was very very unhappy with the code and file structure that I was provided. Is CMSIS like ASF in that it has a bunch of commonly used functions?
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: First LED Blinky not working on SAMD10D14
« Reply #4 on: October 31, 2017, 03:34:17 pm »
it seems as though I would use that instead of my register definitions?
Absolutely!  Defining your own registers is a huge waste of time, and a way to introduce errors.

I have a collection of simple application here https://github.com/ataradov/mcu-starter-projects . They may not work for you as is, if you want to stay within Segger ecosystem, but you may pick some stuff from them. For example GPIO manipulation macros (hal_gpio.h) proved to be extremely useful and it will work for you as is.

I tried using ASF before and I was very very unhappy with the code and file structure that I was provided.
Sounds about right.

Is CMSIS like ASF in that it has a bunch of commonly used functions?
CMSIS has many layers. The most basic and useful one is just a bunch of header files with excellent register definitions. There is no overhead in using them, and that's what I do in my code. Next levels of CMSIS include code and OSes, and it is not excellent, but you don't have to use it.

« Last Edit: October 31, 2017, 03:36:10 pm by ataradov »
Alex
 
The following users thanked this post: n4alpaca

Offline n4alpacaTopic starter

  • Newbie
  • Posts: 9
  • Country: us
Re: First LED Blinky not working on SAMD10D14
« Reply #5 on: November 01, 2017, 01:58:49 am »
I do Have one more question about the solution to my problem. I read that the pin number corresponds to the position of the bit used to manipulate it. So 1<<5 bit shift left so that we get 0b100000 which is in the register labeled as 5 starting from 0. My question is this, What is in the 0th position? There is no Pin 0, so is it nothing?
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: First LED Blinky not working on SAMD10D14
« Reply #6 on: November 01, 2017, 02:03:50 am »
There is no Pin 0, so is it nothing?
It is a bit that would correspond to PA0 (or Px0, in general). Whether this bit is implemented on the device or not is irrelevant. You are working with a relatively small device, so a lot of bits will correspond to noting on the outside of the device.
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf