Hallo,
ich habe ein Problem mit einem XC2287M. Digital I/O funktioniert
einwandfrei. Auch SSC (Syncronous Serial Channel) funktioniert, d.h. ich
erhalte ein SPI-ähnliches Signal am Oszi. Mein Problem ist jedoch, dass
der µC sich nach Senden der Daten in der If-Schleife aufhängt. Hier der
Code:
if(P10_IN_P1==0x00){
P10_OUT_P4=0x00; //Setze LED P10.4
U0C0_SSC_vSendData(0xAA); //Sende Daten
}
P10_OUT_P4=0x01;
}
Der Code steht in der Main-Schleife. Wenn ich den µC resete, kann ich
immer nur ein Signal erzeugen, dann hängt der Controller in der Schleife
fest.
Hier noch der Code für das USIC:
//**********************************************************************
******
// @Module Universal Serial Interface Channel (USIC) U0C0
// @Filename U0C0.C
//----------------------------------------------------------------------
------
// @Controller Infineon XC2287M-104F80
//**********************************************************************
******
#include "MAIN.H"
//**********************************************************************
******
// @Function void U0C0_SSC_vInit(void)
//
//----------------------------------------------------------------------
------
// @Description This is the initialization function of the U0C0
function
// library. It is assumed that the SFRs used by this
library
// are in reset state.
//
//**********************************************************************
******
void U0C0_SSC_vInit(void)
{
-----------------------------------------------------------------------
/// Configuration of the U0C0 Fractional Divider:
///
-----------------------------------------------------------------------
/// - The Fractional divider is selected
/// - The step value STEP = 640
U0C0_FDRL = 0x8280; // load U0C0 fractional divider
register
///
-----------------------------------------------------------------------
/// Configuration of the U0C0 Baudrate Generator:
///
-----------------------------------------------------------------------
/// - The selected BaudRate is 100,000 kbaud
/// - The PreDivider for CTQ, PCTQ = 0
/// - The Denominator for CTQ, DCTQ = 0
/// - The Divider factor PDIV = 249
U0C0_BRGL = 0x0000; // load U0C0 load baud rate generator
// register L
U0C0_BRGH = 0x00F9; // load U0C0 load baud rate generator
// register H
///
-----------------------------------------------------------------------
/// Configuration of the U0C0 Input Control Register:
///
-----------------------------------------------------------------------
/// - Receive input is not selected
///
-----------------------------------------------------------------------
/// Configuration of the U0C0 Interrupt Node Pointer Register:
///
-----------------------------------------------------------------------
U0C0_INPRL = 0x0000; // load U0C0 Interrupt Node Pointer
register
// L
U0C0_INPRH = 0x0000; // load U0C0 Interrupt Node Pointer
register
// H
///
-----------------------------------------------------------------------
/// Configuration of the U0C0 Shift Control:
///
-----------------------------------------------------------------------
/// - Transmit/Receive LSB first is selected
U0C0_SCTRL = 0x0102; // load U0C0 shift control register L
U0C0_SCTRH = 0x0F0F; // load U0C0 shift control register H
///
-----------------------------------------------------------------------
/// Configuration of the U0C0 Transmit Control/Status Register:
///
-----------------------------------------------------------------------
U0C0_TCSRL = 0x0500; // load U0C0 transmit control/status
// register L
U0C0_TCSRH = 0x0000; // load U0C0 transmit control/status
// register H
///
-----------------------------------------------------------------------
/// Configuration of the U0C0 Protocol Control Register:
///
-----------------------------------------------------------------------
U0C0_PCRL = 0x0F47; // load U0C0 protocol control register
L
U0C0_PCRH = 0x0001; // load U0C0 protocol control register
H
///
-----------------------------------------------------------------------
/// Configuration of the U0C0 Protocol Status Register:
///
-----------------------------------------------------------------------
/// - TBIF is set to simplify polling
U0C0_PSR |= 0x2000; // load U0C0 protocol status register
///
-----------------------------------------------------------------------
/// Configuration of the used U0C0 Interrupts:
///
-----------------------------------------------------------------------
///
-----------------------------------------------------------------------
/// Configuration of the used U0C0 Port Pins:
///
-----------------------------------------------------------------------
/// - Receive Pin is not selected for the module
/// - P2.3 is used for USIC0 Channel0 Shift Data Output(DOUT)
/// - P2.5 is used for USIC0 Channel0 Shift Clock Output(SCLKOUT)
/// - P2.6 is used for USIC0 Channel0 Shift Control output0(SELO0)
/// - P2.7 is used for USIC0 Channel0 Shift Control output1(SELO1)
P2_IOCR03 = 0x0090; //set direction register
P2_IOCR05 = 0x0090; //set direction register
P2_IOCR06 = 0x0090; //set direction register
P2_IOCR07 = 0x00A0; //set direction register
}
//**********************************************************************
******
// @Function void U0C0_SSC_vSendData(uword uwData)
//
//----------------------------------------------------------------------
------
// @Description This function clears the transmit buffer Indication
flag
// first & then writes the send data initialization word
into
// the transmit buffer register.
//
// Note:
// In a multiprocessor system the master with this
function
// has the possibility to send data to the selected
slave.
//**********************************************************************
******
void U0C0_SSC_vSendData(uword uwData)
{
while(!(U0C0_PSR & 0x2000)); // wait until tx buffer indication
flag is set
U0C0_PSCR |= 0x2000; // clear transmit buffer indication flag
U0C0_TBUF00 = uwData; // load transmit buffer register
}
//**********************************************************************
******
// @Function ubyte U0C0_SSC_ubTxDataReady(void)
//
//----------------------------------------------------------------------
------
// @Description This function can be used for checking up the status
of the
// transmit shift indication flag U0C0_PSR_TSIF. This
function
// shows when the sending of data has terminated. By
// continuously polling this flag after the function
// U0C0_SSC_vSendData has been called, it is possible to
// establish when U0C0 has terminated its task.
//
//----------------------------------------------------------------------
------
// @Returnvalue 0 if transmitter is busy, else 1
ubyte U0C0_SSC_ubTxDataReady(void)
{
ubyte ubReturnValue;
ubReturnValue = 0;
if(U0C0_PSR & 0x1000) // if sending of data is
terminated
{
ubReturnValue = 1;
U0C0_PSCR |= 0x1000;
}
return(ubReturnValue);
}
Vielleicht kann mir jemand von euch weiterhelfen, da ich mit meinem
Latein am Ende bin.
Gruß Stefan