Ik heb een "hello world" programma gemaakt op mijn Curiosity Nano development board. Dat lijkt te werken.

Nu wilde ik toevoegen dat ook de led blinkt....

Overal waar ik kijk staat dat dit heel eenvoudig is. Lijkt me ook. Maar het lukt me niet.

Het zou met port_pin_set_output_level functie moeten gaan, maar die is niet gedeclareerd.

Ik gebruik mplabx ide v5.50.

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include "definitions.h"                // SYS function prototypes
#include "string.h"
#include "stdio.h"


void udelay (int d)
{
  d *= 48;
  d /= 6;
  while(d--)
    __asm ("  nop\n");
}


void delay_ms (int d)
{
  while (d--)
    udelay (1000);
}




// *****************************************************************************
// *****************************************************************************
// Section: Main Entry Point
// *****************************************************************************
// *****************************************************************************
uint8_t *buf= (unsigned char *) "Hello world.\r\n";
int main ( void )
{
    int t;
    char tbuf[20];
    
    /* Initialize all modules */
    SYS_Initialize ( NULL );
    t=0;
    SERCOM5_USART_Write (buf, strlen ((char*)buf) );
    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );
    
        t++;
        sprintf (tbuf, "%d ", t);  
        SERCOM5_USART_Write (tbuf, strlen ((char*)tbuf) );
        delay_ms (10);
        SERCOM5_USART_Write (buf, strlen ((char*)buf) );
        delay_ms(1000);
        port_pin_set_output_level(PIN_PB10, t&1);
    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}


/*******************************************************************************
 End of File
*/

make[2]: Entering directory '/home/wolff/HarmonyProjects/Myproject/firmware/hello.X'
"/opt/microchip/xc32/v3.00/bin/xc32-gcc"    -g -x c -c -mprocessor=ATSAMD21G17D  -ffunction-sections -fdata-sections -O1 -I"../src" -I"../src/config/default" -I"../src/packs/ATSAMD21G17D_DFP" -I"../src/packs/CMSIS/" -I"../src/packs/CMSIS/CMSIS/Core/Include" -Werror -Wall -MP -MMD -MF "build/default/production/_ext/1360937237/main.o.d" -o build/default/production/_ext/1360937237/main.o ../src/main.c    -DXPRJ_default=default      -mdfp="/opt/microchip/mplabx/v5.50/packs/Microchip/SAMD21_DFP/3.4.116/samd21d" -I "/opt/microchip/mplabx/v5.50/packs/arm/CMSIS/5.4.0/CMSIS/Core/Include" 
../src/main.c: In function 'main':
../src/main.c:77:9: error: implicit declaration of function 'port_pin_set_output_level' [-Werror=implicit-function-declaration]
         port_pin_set_output_level(PIN_PB10, t&1);
         ^~~~~~~~~~~~~~~~~~~~~~~~~

Dit is waarom ik die IDE dingen niet fijn vind. Ik plok een stukje code wat volgens iemand werkt in m'n code en dan moet ik ergens tig menus verder nog iets "aanzetten" of zo om dat werkend te krijgen.

Gewoon: "Dit is de code, dat werkt", is wat ik graag wil hebben. Maar goed. Nu twee uur kwijt aan, hey effe een io pin togglen.

Edit: Er zijn hints dat ik "ASF" moet gebruiken. Maar ik krijg de indruk dat dit bij "atmel studio" hoort en niet bij mplabx. Right? Wrong?

edit: Uiteindelijk blijkt de code om m'n led te togglen te zijn:
LED_Toggle();
Er is ook: LED_Set() en LED_Clear().