Hi there.
I have a problem with the SCI/Lin Module. When transmitting data to my PC I do not receive the first character/byte after reset.
Here is my transmit routine:
void transmit(char sendbuffer[], int len)
{
int i;
if(len < BUFFER_SIZE)
{
for(i=0; i < len; i++)
{
while ((scilinREG->FLR & SCI_TX_INT) == 0)
{
}
scilinREG->TD = sendBuffer[i];
}
}
}
and my SCI inti routine:
void sciInit(void)
{
// bring SCI out of reset
scilinREG->GCR0 = 1U;
// Stop SCILIN / Set SW nRST to 0
scilinREG->GCR1 &= ~(1 << 7);
// Disable all interrupts
scilinREG->CLRINT = 0xFFFFFFFFU;
scilinREG->CLRINTLVL = 0xFFFFFFFFU;
// global control 1
scilinREG->GCR1 =((1 << 25) // enable transmit
| (1 << 24) // enable receive
| (1 << 17) // Continue on Suspend Bit for debugging
| (1 << 5) // internal clock (device has no clock pin)
| ((1-1) << 4) // number of stop bits: 0->1 stop bit | 1->2 stop bits
| (0 << 3) // even parity(1), otherwise odd(0)
| (0 << 2) // disable parity
| (1 << 1)); // asynchronous timing mode
// set baudrate to 115200
// TRM Seite 1643 - 1644 | 25.13.12 Baud Rate Selection Register
// VCLK = 80 MHz
scilinREG->BAUD = 42; // baudrate
// tranmision length
scilinREG->LENGTH = 8 - 1; // length
// set SCI pins functional mode
scilinREG->FUN = ((1 << 2) // tx pin
| (1 << 1) // rx pin
| (0)); // clk pin
// set interrupt level
scilinREG->SETINTLVL=((0 << 26) // Framing error
| (0 << 25) // Overrun error
| (0 << 24) // Pariry error
| (1 << 9) // Receive
| (1 << 8) // Transmit
| (0 << 1) // Wakeup
| (0)); // Break detect
// set interrupt enable
scilinREG->SETINT = ((0 << 26) // Framing error
| (0 << 25) // Overrun error
| (0 << 24) // Pariry error
| (1 << 9) // Receive
| (0 << 8) // Transmit
| (0 << 1) // Wakeup
| (0)); // Break detect
// clear interrupt flags
scilinREG->FLR = 0xFFFFFFFF;
// Start SCILIN
scilinREG->GCR1 |= (1 << 7);
}
I don't know where the problem is. Am i initialising the SCI wrong?
Thanks for helping me.
Dominik