Freescale Semiconductor Microcontrollers Bedienungsanleitung Seite 660

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 892
  • Inhaltsverzeichnis
  • FEHLERBEHEBUNG
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 659
ColdFire V1 Full Chip Simulation Connection
FCS Tutorials
660
Microcontrollers Debugger Manual
Step 9 - Entering User Code
1. Open the user module MyGuessTheNumber.C
2. Insert the following code before the main routine:
#include <stdlib.h>
void PutChar(unsigned char c) {
while (AS1_SendChar(c) == ERR_TXFULL) {
// could wait a bit here
}
}
void PutString(const char* str) {
while (str[0] != '\0') {
PutChar(str[0]);
str++;
}
}
void GuessTheNumber(void) {
int ran = rand() / (RAND_MAX / 9);
AS1_Init();
PutString("Guess a Number between 0 and 9\n");
PutString("Number: ");
for (;;) {
unsigned char c;
if (AS1_RecvChar(&c) == ERR_OK) {
PutChar(c); PutChar(' ');
if(c < '0' || c > '9') {
PutString("not a number, try again\n");
} else if(c == ran + '0') {
PutString("\nCongratulation! You have found the number!");
PutString("\nGuess a new number\n");
ran = rand() / (RAND_MAX / 9);
} else if(c > ran + '0') {
PutString("lower\n");
} else {
PutString("greater\n");
}
PutString("Number: ");
} else {
// could wait a bit here
}
} // for
}
3. Call the function GuessTheNumber in the main routine.
Seitenansicht 659
1 2 ... 655 656 657 658 659 660 661 662 663 664 665 ... 891 892

Kommentare zu diesen Handbüchern

Keine Kommentare

ReSound Azure Handbücher

Bedienungsanleitungen und Benutzerhandbücher für Kopfhörer ReSound Azure.
Wir stellen 1 PDF-Handbücher ReSound Azure zum kostenlosen herunterladen nach Dokumenttypen zur Verfügung Betriebsanweisung