Other Parts Discussed in Thread: MOTORWARE
I am running motorware Lab 20 on a custom board using 2802F and CCS 6.1. I have been running the lab successfully until I incorporated changes in the files for SCI communications. Now the program compiles and loads without any error but when I run it, it get stuck in the loop:
in hal.c
while(PLL_getLockStatus(obj->pllHandle) != PLL_LockStatus_Done) {}
I have following changes in the code:
In hal.c
...
obj->sciaHandle = SCI_init((void *) SCIA_BASE_ADDR, sizeof(SCI_Obj));
...
HAL_setupSCI(handle);
...
CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);
...
GPIO_setPullUp(obj->gpioHandle, GPIO_Number_28, GPIO_PullUp_Enable);
GPIO_setPullUp(obj->gpioHandle, GPIO_Number_29, GPIO_PullUp_Enable);
GPIO_setQualification(obj->gpioHandle, GPIO_Number_28, GPIO_Qual_ASync);
GPIO_setMode(obj->gpioHandle, GPIO_Number_28, GPIO_28_Mode_SCIRXDA);
GPIO_setMode(obj->gpioHandle, GPIO_Number_29, GPIO_29_Mode_SCITXDA);
...
void HAL_setupSCI(HAL_Handle handle) {
HAL_Obj *obj = (HAL_Obj *) handle;
//
// SCIFFTX = 0xE040
SCI_enableChannels(obj->sciaHandle); // SCI reset
SCI_enableTxFifoEnh(obj->sciaHandle); // SCI FIFO transmit enable
SCI_enableTxFifo(obj->sciaHandle); // SCI FIFO transmit reset/reenable
SCI_clearTxFifoInt(obj->sciaHandle); // SCI clear FIFO transmit interrupt flag
SCI_disableTxFifoInt(obj->sciaHandle); // disable FIFO transmit interrupt
SCI_setTxFifoIntLevel(obj->sciaHandle, SCI_FifoLevel_Empty); // FIFO interrupt level
// SCIFFRX = 0x2041
SCI_enableRxFifo(obj->sciaHandle); // SCI FIFO receive reset/reenable
SCI_clearRxFifoInt(obj->sciaHandle); // SCI clear FIFO receive interrupt flag
SCI_disableRxFifoInt(obj->sciaHandle); // disable FIFO receive interrupt
SCI_setRxFifoIntLevel(obj->sciaHandle, SCI_FifoLevel_1_Word); // FIFO interrupt level
// SCI stop bit, parity, loopback, char bits, idle/address mode (SCICCR = 0x07)
SCI_setNumStopBits(obj->sciaHandle, SCI_NumStopBits_One); // SCICCR bit 7
SCI_setParity(obj->sciaHandle, SCI_Parity_Odd); // SCICCR bit 6
SCI_disableParity(obj->sciaHandle); // SCICCR bit 5
//SCI_enableParity(obj->sciaHandle);
SCI_disableLoopBack(obj->sciaHandle); // SCICCR bit 4
SCI_setMode(obj->sciaHandle, SCI_Mode_IdleLine); // SCICCR bit 3
SCI_setCharLength(obj->sciaHandle, SCI_CharLength_8_Bits);// SCICCR bit 0-2
// TX enable, RX enable, RX ERR INT enable, SLEEP, TXWAKE (SCICTL1 = 0x03)
SCI_disableRxErrorInt(obj->sciaHandle); // SCICTL1 bit 6
SCI_disable(obj->sciaHandle); // SCICTL1 bit 5
SCI_disableTxWake(obj->sciaHandle); // SCICTL1 bit 3
SCI_disableSleep(obj->sciaHandle); // SCICTL1 bit 2
SCI_enableTx(obj->sciaHandle); // SCICTL1 bit 1
SCI_enableRx(obj->sciaHandle); // SCICTL1 bit 0
// TXINT enable, RXINT enable, TXEMPTY, TXRDY (SCICTL2 = 0x03)
SCI_enableRxInt(obj->sciaHandle); // SCICTL2 bit 1
SCI_disableTxInt(obj->sciaHandle); // SCICTL2 bit 0
// SCIH-SCIL BAUD - SCI_BAUD = (LSPCLK/(SCI_BRR*8)) - 1
SCI_setBaudRate(obj->sciaHandle, SCI_BaudRate_9_6_kBaud);
// Reset SCI
SCI_enable(obj->sciaHandle);
}
In hal.h
extern interrupt void sciaISR(void);;
...
pie->SCIRXINTA = &sciaISR;