Thanks!
I just try the example and it works. Now i just try to monitor my system and also I want to typ in new values but the problem is that it reacts very strange. If I typ in the start parameter it works fine but after that if I want to change a parameter I always need to tyo it in twice till the system change the value. Why is it so strange?
void zahl_Eingabe(){
if(startTheSystem==0){
printf("Das System wird gestartet.\n");
printf("Bitte geben Sie die Frequenz für das FAD ein.\n");
scanf("%ld", &zahl);
frequencyFromFAD=zahl;
printf("Bitte geben Sie die Amplitude für das FAD ein.\n");
scanf("%ld", &zahl);
amplitudeFromFAD=zahl;
printf("Bitte geben Sie den Schwellwert für das PSD ein.\n");
scanf("%ld",&zahl);
thresholdForThePSD=zahl;
startTheSystem=1;
}
if(controlTheSystem==0){
printf("Der Chris hat keine Ahnung und der Sämann erst recht!\n");
scanf("%s %ld",befehl,&zahl);
//write the frequency to FAD
if(strcmp(befehl,"w1")==0){
send_16bit_Data_To_SPI_Slave(SPI_MASTER_BASE,0x1,zahl);
zahl=0;
befehl=0;
}
//write the amplitude to the FAD
if(strcmp(befehl,"w2")==0){
send_16bit_Data_To_SPI_Slave(SPI_MASTER_BASE,0x1,zahl);
zahl=0;
befehl=0;
}
//write the threshold to the PSD
if(strcmp(befehl,"w3")==0){
send_16bit_Data_To_SPI_Slave(SPI_MASTER_BASE,0x2,zahl); //take care about the slave_select_address
zahl=0;
befehl=0;
}
//read the frequency from the FAD which is generated now
if(strcmp(befehl,"r1")==0){
double countedFreq=0;
countedFreq =count_The_Frequency_Of_The_FAD();
printf("Die Frequenz vom FAD ist momentan auf: %e Hz\n", countedFreq);
countedFreq=0;
zahl=0;
befehl=0;
}
//read the amplitude from the FAD which was give in before
if(strcmp(befehl,"r2")==0){
printf("Die Amplitude vom FAD beträgt momentan: %ld °\n", amplitudeFromFAD);
zahl=0;
befehl=0;
}
//read the threshold from the PSD which was give in before
if(strcmp(befehl,"r3")==0){
printf("Der Schr2wellwert vom PSD beträgt momentan: %ld\n", thresholdForThePSD);
zahl=0;
befehl=0;
}
controlTheSystem=1;
}
}
void task1(void* pdata)
{
while (1)
{
if((startTheSystem==1) & (systemWasBooted==0)){
printf("Das System wird nun gebootet!\n");
systemWasBooted=1;
}
if(((controlTheSystem==0) & (systemWasBooted==1)) | ((controlTheSystem==1) & (systemWasBooted==1))){
controlTheSystem=0;
printf("Controlflag: %d\n", controlTheSystem);
system_Monitoring(PE_PIO_BASE,MME_PIO_BASE,SPDM_PIO_BASE);
}
OSTimeDlyHMSM(0, 0, 2, 0);
}
}
void task2(void* pdata)
{
while (1)
{
zahl_Eingabe();
OSTimeDlyHMSM(0, 0, 1, 0);
}
}
/* The main function creates two task and starts multi-tasking */
int main(void)
{
OSTaskCreateExt(task1,
NULL,
(void *)&task1_stk,
TASK1_PRIORITY,
TASK1_PRIORITY,
task1_stk,
TASK_STACKSIZE,
NULL,
0);
OSTaskCreateExt(task2,
NULL,
(void *)&task2_stk,
TASK2_PRIORITY,
TASK2_PRIORITY,
task2_stk,
TASK_STACKSIZE,
NULL,
0);
OSStart();
return 0;
}
Thanks in advance for the help!