Thread Starter

Manjesh Gowda

Joined Oct 19, 2020
88
Hello,
I am newbie in programming the microcontroller. I would like to test the micro by blinking the LED in a pin. The micro is SAMR35J18B and I am using ATMEL ICE programmer and ATMEL studio software for the programming. I am able to detect the micro in the software but I could not find proper program to blink the led. I tried few and did not work out. The pin PB02 is connected to LED through a transistor. I will attach the code which i used. Could someone tell me what is wrong with the program or please attach a link for a basic LED blink program. Thank you.

C:
#include "sam.h"

int main(void)
{
    unsigned int i;

    /* Initialize the SAM system */
    SystemInit();
    REG_PORT_DIR0 |= 1<<2;

    /* Replace with your application code */
    while (1)
    {
        REG_PORT_OUTTGL0 = PORT_PB02;
        re
        for (i=0;i<100000;i++)
        {
        }
    }
}
Moderator edit: code tags added like this [code]… your code …[/code]
 
Last edited:

Pushkar1

Joined Apr 5, 2021
416
Hello,
I am newbie in programming the microcontroller. I would like to test the micro by blinking the LED in a pin. The micro is SAMR35J18B and I am using ATMEL ICE programmer and ATMEL studio software for the programming. I am able to detect the micro in the software but I could not find proper program to blink the led. I tried few and did not work out. The pin PB02 is connected to LED through a transistor. I will attach the code which i used. Could someone tell me what is wrong with the program or please attach a link for a basic LED blink program. Thank you.

#include "sam.h"


int main(void)
{
unsigned int i;

/* Initialize the SAM system */
SystemInit();
REG_PORT_DIR0 |= 1<<2;

/* Replace with your application code */
while (1)
{
REG_PORT_OUTTGL0 = PORT_PB02;
re
for (i=0;i<100000;i++)
{
}
}
}
Have you compiled code, do you get an error after compiling the code?

Please use the code tag to post to code
 
Last edited:

Thread Starter

Manjesh Gowda

Joined Oct 19, 2020
88
Yes I have compiled it and I did not get any error. I was able to flash the code as well. The problem is i am not getting enough voltage at the pin PB02 to turn on the gate of the transistor inorder to turn on the led.
 

BobTPH

Joined Jun 5, 2013
9,003
I don’t know the micro or the compiler you are using, but I certainly don't see anything in your program that would flash an LED.

Bob
 

BobTPH

Joined Jun 5, 2013
9,003
Here us what an LED blink orogram looks loke on a pic micro. Your program should look similar in structure, though the names of things will be different.
Code:
void blink()
{
    // Set A0 as an output
    TRISAbits.TRISA0 = 0;

    while(1)
    {
        // turn the LED on
        LATAbits.LATA0 = 1;
        // wait 1/2 a second
        __delay_ms(500);
        // turn the LED off
        LATAbits.LATA0 = 0;
        // wait again
        __delay_ms(500);
    }
}
Bob
 
Top