Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Le cas de communication samd21 et raspberry ne fonctionne pas #121

Closed
moustafa-x opened this issue Apr 18, 2023 · 18 comments
Closed

Le cas de communication samd21 et raspberry ne fonctionne pas #121

moustafa-x opened this issue Apr 18, 2023 · 18 comments

Comments

@moustafa-x
Copy link

Pouvez-vous aider à résoudre un problème !
#include "tpl_os.h"
//the READY tasks state definition conflicts with registers definition (in sam.h)
#undef READY
#include "sam.h"
#include <pinAccess.h>
#include "board/iutNantes/include/timer.h"
#include "board/iutNantes/include/oled.h"
#include <eic.h>
#include "serial.h"
#include <errno.h>
#include <stdio.h> //printf
//distance en cm.
volatile unsigned int range;

int main(void)
{
pinMode(PORTB,9,OUTPUT); //TRIGGER pin
pinMode(PORTB,15,INPUT); //ECHO pin
EICInitClock(F1MHZ);
TCinitClock(F1MHZ,3); //1 pulse/us
OLEDInit(0);
SERIALInit(115200);
range = 0;
StartOS(OSDEFAULTAPPMODE);
return 0;
}

TASK(displayTask)
{
OLEDSetLine(0);
OLEDPrintString("distance ");
OLEDPrintInt(range,3);
OLEDPrintString("cm.");
TerminateTask();
}

TASK(timeoutTask)
{
OLEDSetLine(0);
OLEDPrintInt(range,3);
OLEDPrintString(" Pas de capteur!");
TerminateTask();
}

TASK(measureTask)
{
//trigger
digitalWrite(PORTB,9,1);
for(volatile int i=0;i<1000;i++);
digitalWrite(PORTB,9,0);

//lancement alarme du timeout
SetRelAlarm(activateTimeout,35,0);
TerminateTask();

}

ISR(triggerISR)
{
if(digitalRead(PORTB,15) == 1)
{
//front montant. Lancement timer TC3.
TC3->COUNT16.COUNT.reg = 0; //init val
TC3->COUNT16.CTRLA.reg = 2; //run, sans prescaler.
} else {
unsigned int mes = TC3->COUNT16.COUNT.reg; //1 tick/us
range = mes/58; //conversion en cm.
TC3->COUNT16.CTRLA.reg = 0; //arret (non necessaire)

}
CancelAlarm(activateTimeout);

}
typedef struct {
uint16_t id; // ID du capteur
uint16_t value; // Valeur du capteur
} SensorData;
TASK(STask){
SensorData sensorData;
sensorData.id = 1; // ID du capteur
sensorData.value = range; // Valeur du capteur
char s[5]={'s','s','s','s','s'};
SERIALPutString(s); // Envoi du message initial
for (int i = 0; i < sizeof(sensorData); i++) {
SERIALPutchar(((uint8_t)&sensorData + i));}

TerminateTask();
}

@mbriday
Copy link
Contributor

mbriday commented Apr 18, 2023 via email

@moustafa-x
Copy link
Author

Aucune donnée n'est envoyée. Je ne connaissais pas de solution.

@moustafa-x
Copy link
Author

Screenshot_2023-04-18-17-41-08-779_com google android gm
aucune donnée n'a été envoyée

@jlbirccyn
Copy link
Member

Quelle est la description OIL de la tâche STask ?

@moustafa-x
Copy link
Author

OIL_VERSION = "2.5";

IMPLEMENTATION trampoline {
/* This fix the default STACKSIZE of tasks /
TASK {
UINT32 STACKSIZE = 800 ;
};
/
This fix the default STACKSIZE of ISRs */
ISR {
UINT32 STACKSIZE = 500 ;
} ;
};

CPU blink {
OS config {
STATUS = EXTENDED;

BUILD = TRUE {
  TRAMPOLINE_BASE_PATH = "../../../../../../";	
  APP_SRC = "board/iutNantes/src/adc.c";
  APP_SRC = "board/iutNantes/src/oled.c";
  APP_SRC = "board/iutNantes/src/serial.c";
  APP_SRC = "board/iutNantes/src/dac.c";
  APP_SRC = "board/iutNantes/src/redirectPrintf.c";
  APP_SRC = "board/iutNantes/src/timer.c";
  CFLAGS  = "-I board/iutNantes/include"; 
  APP_SRC = "blink.c";
  APP_NAME = "blink.elf";
  CFLAGS  = "-O3 -std=c99"; 
  COMPILER = "arm-none-eabi-gcc";
  ASSEMBLER = "arm-none-eabi-as";
  LINKER = "arm-none-eabi-ld";
  COPIER = "arm-none-eabi-objcopy";
  SYSTEM = PYTHON;
};

SYSTEM_CALL = TRUE;
MEMMAP = TRUE {
  COMPILER = gcc;
  LINKER = gnu_ld { SCRIPT = "script.ld"; };
  ASSEMBLER = gnu_as;
  MEMORY_PROTECTION = FALSE;
};

};

APPMODE std {};

TASK measureTask {
PRIORITY = 5;
AUTOSTART = FALSE;
ACTIVATION = 1;
SCHEDULE = FULL;
};

ALARM activatePeriodic {
COUNTER = SystemCounter;
ACTION = ACTIVATETASK {
TASK = measureTask;
};
AUTOSTART = TRUE {
APPMODE = std;
ALARMTIME = 100;
CYCLETIME = 100;
};
};

TASK timeoutTask {
PRIORITY = 3;
AUTOSTART = FALSE;
ACTIVATION = 1;
SCHEDULE = FULL;
};

ALARM activateTimeout {
COUNTER = SystemCounter;
ACTION = ACTIVATETASK {
TASK = timeoutTask;
};
AUTOSTART = FALSE;
};

TASK displayTask {
PRIORITY = 1;
AUTOSTART = FALSE;
ACTIVATION = 1;
SCHEDULE = FULL;
};

ALARM activateDisplay {
COUNTER = SystemCounter;
ACTION = ACTIVATETASK {
TASK = displayTask;
};
AUTOSTART = TRUE {
APPMODE = std;
ALARMTIME = 1000;
CYCLETIME = 1000;
};
};

TASK STask {
PRIORITY = 4;
AUTOSTART = FALSE;
ACTIVATION = 1;
SCHEDULE = FULL;
};

ALARM comTASK {
COUNTER = SystemCounter;
ACTION = ACTIVATETASK {
TASK = STask;
};
AUTOSTART = TRUE {
APPMODE = std;
ALARMTIME = 1000;
CYCLETIME = 1000;
};
};

ISR triggerISR {
CATEGORY = 2;
PRIORITY = 30;
STACKSIZE = 256;
SOURCE = EIC_IRQ {
PIN = PB15 {
TRIGGER = BOTH;
PULL = NONE;
FILTERING = FALSE;
};
};
};

};

@jlbirccyn
Copy link
Member

jlbirccyn commented Apr 18, 2023

Ajoutez un affichage sur l'OLED dans STask pour savoir si cette tâche s'exécute.

@moustafa-x
Copy link
Author

pour le moment je ne l'ai pas .
Y a-t-il un autre moyen ?

@jlbirccyn
Copy link
Member

Je n'ai pas compris votre réponse. Vous n'avez pas quoi ?

@TrampolineRTOS TrampolineRTOS deleted a comment from moustafa-x Apr 18, 2023
@moustafa-x
Copy link
Author

afficheur OLED

@jlbirccyn
Copy link
Member

Dans ce cas, changez l'état d'une des LED de la carte.

@moustafa-x
Copy link
Author

Même problème, pouvez-vous voir si le code est correct ?
Je vous ai envoyé un e-mail tout les fichiers que j'ai utilisé.

@jlbirccyn
Copy link
Member

Je ne reçois pas vos email (je ne sais pas pourquoi). Vous pouvez attacher des fichiers ici.

@moustafa-x
Copy link
Author

C'est tout fichier avec toutes les librairies

@jlbirccyn
Copy link
Member

jlbirccyn commented Apr 18, 2023

Vous n'avez pas ajouté le clignotement de la LED ? Vous n'avez pas la carte sous la main ?

@jlbirccyn
Copy link
Member

Je veux savoir si cette tâche s'exécute. Ajoutez un clignotement de LED dans STask. Et testez avant que la LED clignote bien dans une tâche que vous savez s'exécuter correctement.

@moustafa-x
Copy link
Author

j'ai essayé plusieurs fois mais malheureusement j'ai aucun fonctionnalités dans Stask

@jlbirccyn
Copy link
Member

  1. La LED clignote si vous mettez le code de changement de son état dans displayTask ?
  2. Si oui, qui se passe-t-il si vous faite clignotez la LED dans STask et que vous commentez le reste du code de STask (ie STask ne fait que clignoter la LED et rien d'autre.

@moustafa-x moustafa-x reopened this May 3, 2023
@moustafa-x
Copy link
Author

/ #
githab.zip

Essalamou Alaikom .
j'espère que vous allez bien?.

// j'ai fait dans tout les task une led au fonctionne normal
// jai réussi la trasmision de data mais le cas
(SERIALPutchar(((uint8_t*)&sensorData + i));) ne renvoie rien
// cette intrpation(triggerISR) ne fonctionne pas.

Cordialement.

@jlbirccyn jlbirccyn closed this as not planned Won't fix, can't repro, duplicate, stale Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants