Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

SDK • Re: the RP2040 in C and command lines (le RP2040 en C et lignes de commandes)

$
0
0
Hello,
Thank you all for your replies.
I usually code as follows:

Code:

/* *  Projet XYZ. *  version 19-1125 *  pour AVR-ATMEGA1284P*/#include <avr/io.h>#include <avr/interrupt.h>#include "mesRegistres.h"//  *****************************************************************************************#define isREG(n) bitREG&(1<< (n) )#define onREG(n) bitREG|=(1<< (n) )#define offREG(n) bitREG&=~(1<< (n) )//  *****************************************************************************************volatile uint64_t oneCount = 0;volatile uint64_t twoCount = 0;uint8_t bitREG = 0, lesProcess = 0;//  *****************************************************************************************void TimerChrono(){   //  Timer 0, 8 bits.    TCCR0A=(1<<1);    //  MODE CTC    TCCR0B=(1<<1);    //  prescaler de 64    OCR0A = 249;      //  250-1 => 1 Khz.    OCR0B = 79;       //  80-1  => 3.125 Khz.    TIMSK0&=~(1<<0);  //  désactiver l'interruption sur le débordement timer    TIMSK0|=(1<<1);   //  activer l'interruption sur le débordement OCR0A    TIMSK0|=(1<<2);   //  activer l'interruption sur le débordement OCR0B}ISR(TIMER0_COMPA_vect){  ++oneCount;  if(isREG(0)){oneCount = 0; offREG(0);}  //  RAZ oneCount}ISR(TIMER0_COMPB_vect){  ++twoCount;  if(isREG(1)){twoCount = 0; offREG(1);}  //  RAZ twoCount}//  *****************************************************************************************int main(){  while(1){    ++lesProcess;    switch(lesProcess){      case 1 :              //  code process one              break;      case 2 :              //  code process two              break;      case 3 :              //  code process three              break;      case 4 :              //  code process four              break;      case 5 :              //  code process .x.              break;      default :              leProcess = 0;              break;    }    //    //  autre code...    //  }  return 0;}
le code comme :

Code:

digitalWrite(myPIN, LOW);
is fine, but takes up a lot of resources, particularly programme RAM, and requires too many machine cycles to execute.

I am looking for the lowest possible level, closest to the hardware, which, in my humble opinion, helps with understanding and faster progress.
I'm going to start looking at the SDK. I already have about ten RP2040s, and microPython is “hurting” my eyes.

Thanks again to all of you.

Statistics: Posted by Thihii — Tue Nov 18, 2025 5:59 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles