I want to be short. I got one Pico yesterday and I spent the evening yesterday making a blink.c (from Raspberry site) work on mi Pico through Linux and I made it work.
Now I want to make myblink.c which is a blink.c in Low Level programming (registers and all of that). But the last time I did a low level programming was 5 years ago on a MSP430, and I can't remember the basics anymore. Could someone please help me? Sorry. How can I make this low level programming in C compile a uf2 file which makes my raspberry pi pico blink his LED which is on the 25 pin? It compile, but the Pico doesnt do nothing. Obviously this code is not correct, what I can change to make it work? Thank you.
Below are myblink.c and CMakeLists.txt:
#include <stdio.h>
#include <stdlib.h>
#define SIO_BASE 0xd0000000
#define GPIO_IN 0xd0000004
#define GPIO_HI_IN 0xd0000008
#define GPIO_OUT 0xd0000010
#define GPIO_OUT_SET 0xd0000014
#define GPIO_OUT_CLR 0xd0000018
#define GPIO_OUT_XOR 0xd000001c
#define GPIO_OE 0xd0000020
#define GPIO_OE_SET 0xd0000024
#define GPIO_OE_CLR 0xd0000028
#define GPIO_OE_XOR 0xd000002c
#define GPIO_HI_OUT 0xd0000030
typedef unsigned int uint;
void write32(uint dst, uint val){
uint dst_u = (uint)dst;
dst_u = val;
return;
}
uint read32(uint src){
uint src_u = (uint)src;
return src;
}
int main(){
uint gpoes = read32(GPIO_OE);
gpoes |= (1<<25);
write32(GPIO_OE, gpoes);
//int i=0;
while(1){
//turn on pin 0
write32(GPIO_OUT, 1<<25);
//delay
//while (i < 0x80000){
// i++;
//}
//turn off pin 0
//write32(GPIO_OUT_CLR, 1<<25);
//delay
//while (i < 0x80000){
// i++;
//}
}
}
cmake_minimum_required(VERSION 3.12)
# PUll in PICO SDK (must be before project)
include(pico_sdk_import.cmake)
project(myblink C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR})
# Initialize the SDK
pico_sdk_init()
add_executable(myblink
myblink.c
)
# Pull in our pico_stdlib which pulls in common
target_link_libraries(myblink pico_stdlib)
# create map/bin/hex file etc.
pico_add_extra_outputs(myblink)