endless transmitt sci n qsci

Khairul Nizam <[email protected]> Wed, 30 Aug 2006 03:13:13 -0700 (PDT)
Newsgroups gmane.comp.hardware.motorola.microcontrollers
Message-ID <[email protected]>
hi all
   
  i had problem with my code. i had created simple interrupt program to send a character each time i typed a character in hyperterminal (trough qsci module). it works, but it keep transmitting the character even i didnt type anything after that (code in blue colour)
   
  second problem was to send characters using Queue....it does not works (codes in red colour).
   
  below are the codes...hope someone can help me how to figure it out...
   
  thank you all...
   
   
  //////////////////////////
// Project Stationery  //
//////////////////////////
  #include <stdio.h>
#include "mpc555.h"
   
     UINT32 counter = 0 ;  // Global for ISR to hold the 
          // number of PIT interrupts
   UINT32 loopctr = 0 ;  // Loop counter for main loop
  asm void system_call();
void PIT_ISR();
void SCI_Int (void);
  void init555()    // Simple MPC555 Initialization
{
   USIU.SYPCR.R = 0xffffff03; // Disable watchdog timer 
   USIU.PLPRCR.B.MF = 0x009; // Run at 40MHz for 4MHz crystal
   while(USIU.PLPRCR.B.SPLS == 0); // Wait for PLL to lock 
   UIMB.UMCR.B.HSPEED = 0; // Run IMB at full clock speed           
}
  
void initPIT() 
{
       // STEP 1: MODULE SPECIFIC INITIALIZATION
   USIU.PITC.B.PITC = 4000; // Setup count value.
   USIU.PISCR.B.PITF = 1; // Freeze enabled to stop PIT
   USIU.PISCR.B.PTE = 1; // PIT enabled to start counting   
   
       // STEP 2: LEVEL ASSIGNMENT
   USIU.PISCR.B.PIRQ = 0x80; // Level 0 PIT interrupt
         // STEP 3: ENABLE INTERRUPT
   USIU.PISCR.B.PIE = 1 ; // Enable PIT interrupt
         // STEP 4: SET APPROPRIATE SIMASK BITS
   USIU.SIMASK.R = 0x40000000;  // Enable level 0; others disabled
} 
  
void initSci() 
{
       // STEP 1: MODULE SPECIFIC INITIALIZATION
       // Initialize the SCI for simple operation
    QSMCM.SCC1R0.B.SC1BR = 40000000/32/57600; // Set baud rate
    QSMCM.SCC1R1.B.TE = 1; // Transmitter enable
    QSMCM.SCC1R1.B.RE = 1; // Receiver enable
       // Initialize buffer variables
         // STEP 2: LEVEL ASSIGMENT
    QSMCM.QDSCI_IL.B.ILDSCI = 5; // define SCIIRQ at level 5
         // STEP 3: ENABLE INTERRUPT
    QSMCM.SCC1R1.B.RIE = 1; // Enable receive interrupts only
         // STEP 4: SET APPROPRIATE SIMASK BITS
    USIU.SIMASK.R = 0x00100000; // Enable level 5; others disabled 
    
    //TAKLEH BUAT QTHE TERUS LEH ASSIGN LEVEL 3 KE....KENA SHARE NGAN SCI GAKKE
} 
   
  main()
{
 init555();    // Perform a simple 555 initialization
// initPIT(); 
 initSci();   // Init PIT to generate interrupts
  asm(" mtspr EIE, r3"); // FINAL STEP: SET MSR[EE], MSR[RI] BITS
     while(1)     // Wait for PIT interrupts 
    {
    loopctr++;
     initSci();   // Init PIT to generate interrupts
  asm(" mtspr EIE, r3"); // FINAL STEP: SET MSR[EE], MSR[RI] BITS
    // Increment loopctr for something to do
    }        
}
  void SCI_Int (void)   //apsal interrupt berlaku sekali jek?
{ 

  
 while(QSMCM.SC1SR.B.TDRE ==0); // check transmit data reg empty.....tertinggl 
 QSMCM.SC1DR.R = 'X';          // not using Q:data to be transmit 
  /*
   QSMCM.QSCI1CR.B.QTSZ=7;  //using Q
   while(QSMCM.SC1SR.B.TC==0);
   if(QSMCM.SC1SR.B.TC==1)
  {
   QSMCM.SCTQ[1].R='A';
   QSMCM.SCTQ[2].R='B';
   QSMCM.SCTQ[3].R='C';
   QSMCM.SCTQ[4].R='D';
   QSMCM.SCTQ[5].R='E';
   QSMCM.SCTQ[6].R='F';
   QSMCM.SCTQ[7].R='G';

  }
   if (QSMCM.QSCI1SR.B.QTHE==1)
  {
   // QSMCM.QSCI1SR.B.QTHE=0;
 
  }
  
 QSMCM.SCC1R1.B.TE=1;
  QSMCM.QSCI1CR.B.QTE=1;
 
 /*/
   }  
  void PIT_ISR()
{ 
//counter++;
 // printf("level 0 entered");
       
}
  
void Ext_Isr()
{ 
   

 		
---------------------------------
Stay in the know. Pulse on the new Yahoo.com.  Check it out. 

[Non-text portions of this message have been removed]



-----------------------------------------------------------
To learn more about Freescale Microcontrollers, please visit
http://www.freescale.com/mcu


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/MPC500/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/