Forum: Mikrocontroller und Digitale Elektronik Printf Ausgabe klappt nicht


von juppo (Gast)


Lesenswert?

Hallo an alle

Beschäftige mich mit dem Entwicklungssystem von i-system if-dev

Hampel schon den ganzen Tag herum.

Wenn ich die printf Routine herauslasse läuft alles wunderbar auch mit
"sendchar" .

Aber wenn printf mit eingebunden wird hängt das System.

Für jede Schützenhilfe dankbar.

Gruss Juppo

#include <stdio.h>

#include <stdlib.h>
#include "lpc213x.h"
//#include <AsystTrace.h>
//#include "Main.h"
//#include "Test.h"
//#include "CPUTest.h"
#define CR     0x0D


int   iCounter=0;
int   iInterruptCounter=0;
int   iLEDStatus=0;
int   on;
int   off;
long  a;
int temp;
// Read the readme.txt for more explanation on the DEBUG define
// for the final application comment below define
#define DEBUG

void wait(void)
{
int i,a;
for (i=0;i<0xfffff;i++)
  {
   a=a-a;
   }
  }


  void init_serial2()
  {
  /* initialize the serial interface   */
  PINSEL0 = 0x00050000;           /* Enable RxD1 and TxD1
      */
  U1LCR = 0x83;                   /* 8 bits, no Parity, 1 Stop bit
      */
  U1DLL = 0x78;                   /* 9600 Baud Rate @ 14,7546MHz VPB
Clock    */
  U1LCR = 0x03;                   /* DLAB = 0
  }    */

  }

void init_serial(void)
  {               /* Initialize Serial Interface       */
  PINSEL0 = 0x00050000;                  /* Enable RxD1 and TxD1 
*/
  U1LCR = 0x83;                          /* 8 bits, no Parity, 1 Stop 
bit     */
  U1DLL = 76;                            /* 9600 Baud Rate @ 15MHz VPB 
Clock  */
//  U1DLL = temp;                            /* 9600 Baud Rate @ 15MHz 
VPB Clock  */
  U1LCR = 0x03;

                /* DLAB = 0                          */
  }

int sendchar (int ch)  {                 /* Write character to Serial 
Port    */

  if (ch == '\n')  {
    while (!(U1LSR & 0x20));
    U1THR = CR;                          /* output CR */
  }
  while (!(U1LSR & 0x20));
  return (U1THR = ch);
}


int getkey (void)  {                     /* Read character from Serial 
Port   */

  while (!(U1LSR & 0x01));

  return (U1RBR);
}

void sendhex (int hex) {                   /* Write Hex Digit to Serial 
Port  */
  if (hex > 9) sendchar('A' + (hex - 10));
  else         sendchar('0' +  hex);
}

void sendstr (char *p) {                   /* Write string */
  while (*p) {
    sendchar (*p++);
  }
}
void __gccmain()
{
}

int main(void)
{

#ifdef DEBUG
//  long a ;   // startup delay about 2 sec. for Debugging purposes
  a = 100000;        // value 100.000 seems enough against run away
  while(a--);        // loop the CPU until Debugger can stop it
#endif
U0IER = 0x00;            //Claer Interrupt
VPBDIV = 0x01;

//  CPU_Init();       // delete LED's, switch on PLL to max. Speed => 
refer AN10331
//  on  = 1000;       // LED on delay value
//  off = 3000;       // LED off delay value

//  on  = 100000;       // LED on delay value
//  off = 300000;       // LED off delay value

  init_serial();
  IO0DIR=0x00000001;
  temp=9000;
  while(1)
  {
/*    Type_Simple();
    Type_Arrays();
    Type_Pointers();
    Type_Struct();
    Type_Bitfields();
    Type_Enum();
    Type_FunctionPointer();
    Type_Mixed();

    Address_GlobalVariables();
    Address_TestScopes();
    Address_DifferentFunctionParameters();
    CPU_Pointers();
    CPU_Recursion();
 */
//  IO0CLR|=IO_LED;
  //printf("Hallo Arm 2138");
  //if(temp<1000)temp++; else temp=1;
 // sendhex(25);
 // sendchar(13);
 // sendchar(10);
  printf("%d",temp);
  sendstr("Hallo ARM LPC2138\n");
  sendchar(13);
  sendchar(10);
  //printf("Hallo World");

  IO0CLR=0x00000001;
  a = temp;        // value 100.000 seems enough against run away
  while(a--);        // loop the CPU until Debugger can stop it
  IO0SET=0x00000001; //LED off
//    Toggle_LED();
  a = temp;        // value 100.000 seems enough against run away
  while(a--);        // loop the CPU until Debugger can stop it
  }
}

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.