Silicon Laboratories Stepper Machine Bedienungsanleitung Seite 25

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 36
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 24
AN155
Rev. 1.1 25
unsigned char Tzero; // initial period, sqrt(2/alpha)
unsigned char PatternIndex; // index for step pattern, modulus 8 counter
bit Forward; // 1 for forward, 0 for reverse
bit doneFlag; // done flag used for Timer ISR handshake
unsigned char motorState; // motor state variable
//
// UART Global Variables
// UART receiver buffer
char idata readBuffer[READ_BUFFER_SIZE];
// UART transmitter buffer
char idata writeBuffer[WRITE_BUFFER_SIZE];
unsigned char writeIndex; // points to next free write byte
unsigned char readIndex; // points to next free read byte
unsigned char writeCount; // number of bytes in write buffer
unsigned char readCount; // number of bytes in read buffer
bit TX_Idle; // flag set when TX buffer is empty
//-----------------------------------------------------------------------------
// MAIN Routine
//-----------------------------------------------------------------------------
//
// The main function initializes everything and then services the user
// interface. The user interface parses characters from the UART and
// executes basic commands. There are three interrupt service routines
// which function in the background - The Timer_ISR which controls the
// stepper motor; The UART_ISR which moves characters to/from the buffers;
// and the INT0_ISR that handles the pushbutton switch commands.
//
void main (void)
{
char theChar; // the character to be parsed
unsigned int newP; // new position to move to
SYSCLK_Init (); // Init system clock to 24.5MHz
PORT_Init (); // Init crossbar and GPIO
Timer_Init(); // Init T0 for stepper motor and
// T1 for Baud rate
UART_Init(); // Init UART
Motor_Init(); // Init motor global variables
EA = 1; // enable global interrupts
putc('>'); // display prompt
while(1) // main loop
{
if(LED==ON) // display position while moving
{
putuint(Position); // display position
puts(" "); // blank out trailing characters
putc('\r'); // overwrite line by not using linefeed
delay(); // delay sets display update rate
}
else
{
if(doneFlag)
{
doneMsg(); // if done display message
}
Seitenansicht 24
1 2 ... 20 21 22 23 24 25 26 27 28 29 30 ... 35 36

Kommentare zu diesen Handbüchern

Keine Kommentare