Other Parts Discussed in Thread: MOTORWARE, C2000WARE, CONTROLSUITE
Tool/software: Code Composer Studio
Ref: https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/334989#pi320995=1
I have implemented a similar structure by Maria Todorova and other, nice discussions, I have UART-TX working on 115K2 (after changing the CLK/PLL since I use 20MHz XOSC for 90MHz SYSCLK) but not sure what going in UART-RX since it not working too well.
I have added several things in hal.c/h, copied over the sci.h/c to project folder to fix BAUD rate for F28069M via enum listing. UART-TX is working good.
Do you have working code or perhaps take a look into attached for the proposed solution?, interrupt did response but it not collecting RX data for some reason.
This is the code below:
//====================================================
//====================================================SCI Receive Data ISR
// Purpose :
// Input :
// Output :
// Note :
// Status :
//====================================================
interrupt void SCI_RX_ISR(void)
{
SCI_Obj *sci = (SCI_Obj *)halHandle->sciAHandle;
bool status;
status = (bool) ((sci->SCIRXST & SCI_SCIRXST_RXRDY_BITS) >> 6);
//if(SCI_rxDataReady(halHandle->sciAHandle)==1)
if (status == true)
{
rxCommand[rxCommandPtr] = SCI_read(halHandle->sciAHandle);
rxCommandPtr++;
if (rxCommand[rxCommandPtr]=='\n')
{
ifEOFDetected=true;
}
//SCI_write_char(halHandle->sciAHandle, rev_data);
}
SCI_clearRxFifoOvf(halHandle->sciAHandle);
SCI_clearRxFifoInt(halHandle->sciAHandle);
PIE_clearInt(halHandle->pieHandle,PIE_GroupNumber_9); // Acknowledge interrupt from PIE group 9
}
/*****************************************************************************
* Copyright (C) 2020 : AOT, Leduc.
*
* All Right Reserved.
*****************************************************************************
*
* FILENAME : ZptintF.c/h
* PURPOSE : Send ASCII based message into USB (CDC) or UART stream
* AUTHOR : Richard Payne
* REVISION :
* History : 3A: Upgrade code to match ESM project including session Log L2(....). \
* : 3A: Updated Welcome Message. Along with advanced Augment support as from ESM.
* NOTE :
* Setup : Make use of USB (CDC) or UART0 port
* :
* :
******************************************************************************/
#include "Universal_Macro.h"
//-------------------------------------MotorWare/C2000Ware Lib.
#include "hal.h"
#include "user.h"
#include "hal_obj.h"
//#include "sw/drivers/sci/src/32b/f28x/f2806x/sci.h"
//-------------------------------------Local Project Lib.
#include "RVP_Main.h"
#include "UART_zPrintf.h"
#include "Detokeniser.h"
#include "UART_Command.h"
#include "UART_SCI.h"
#include "SCI.h"
//====================================================
//====================================================HAL_setupSCI
// Purpose :
// Input :
// Output :
// Note :
// Status :
//====================================================
void HAL_setupSCI(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *) handle;
// Initialize all SCI registers based on your requirement. This is only example.
// SCI stop bit, parity, loopback, char bits, idle/address mode
SCI_setNumStopBits(obj->sciAHandle, SCI_NumStopBits_One);
//SCI_setParity(obj->sciAHandle, SCI_Parity_Odd);
SCI_disableParity(obj->sciAHandle);
SCI_disableLoopBack(obj->sciAHandle);
SCI_setMode(obj->sciAHandle, SCI_Mode_IdleLine);
SCI_setCharLength(obj->sciAHandle, SCI_CharLength_8_Bits);
// TX enable, RX enable, RX ERR INT enable, SLEEP, TXWAKE (SCICTL1 = 0x03)
SCI_disableRxErrorInt(obj->sciAHandle);
SCI_disable(obj->sciAHandle);
SCI_disableTxWake(obj->sciAHandle);
SCI_disableSleep(obj->sciAHandle);
SCI_enableTx(obj->sciAHandle);
SCI_enableRx(obj->sciAHandle);
SCI_enableTxFifo(obj->sciAHandle);
SCI_enableTxFifoEnh(obj->sciAHandle);
// TXINT enable, RXINT enable, TXEMPTY, TXRDY (SCICTL2 = 0x03)
//SCI_enableRxInt(obj->sciAHandle);
SCI_enableRxFifoInt(obj->sciAHandle);
SCI_setRxFifoIntLevel(obj->sciAHandle, SCI_FifoLevel_1_Word);
SCI_disableTxInt(obj->sciAHandle);
// SCIH-SCIL BAUD - SCI_BAUD = (LSPCLK/(SCI_BRR*8)) - 1
SCI_setBaudRate(obj->sciAHandle, SCI_BaudRateRVP_115_2_kBaud); //SCI_BaudRate_19_2_kBaud
// Reset SCI
SCI_enable(obj->sciAHandle);
// enable SCI interrupt
PIE_enableInt(obj->pieHandle, PIE_GroupNumber_9, PIE_InterruptSource_SCIARX);
// enable CPU interrupt
CPU_enableInt(obj->cpuHandle, CPU_IntNumber_9);
}
//====================================================
//====================================================HAL_setupSCI
// Purpose :
// Input :
// Output :
// Note :
// Status :
//====================================================
void SCI_write_char(SCI_Handle sciHandle,char a)
{
SCI_Obj *sci = (SCI_Obj *)sciHandle;
while(SCI_getTxFifoStatus(sci) == SCI_FifoStatus_4_Words) { }
SCI_write(sci, a);
}
//====================================================
//====================================================HAL_setupSCI
// Purpose :
// Input :
// Output :
// Note :
// Status :
//====================================================
void SCI_write_str(SCI_Handle sciHandle, char* str)
{
while(*str != 0)
{
SCI_write_char(sciHandle, *str++);
}
}
//====================================================
//====================================================SCI Receive Data ISR
// Purpose :
// Input :
// Output :
// Note :
// Status :
//====================================================
interrupt void SCI_RX_ISR(void)
{
SCI_Obj *sci = (SCI_Obj *)halHandle->sciAHandle;
bool status;
status = (bool) ((sci->SCIRXST & SCI_SCIRXST_RXRDY_BITS) >> 6);
//if(SCI_rxDataReady(halHandle->sciAHandle)==1)
if (status == true)
{
rxCommand[rxCommandPtr] = SCI_read(halHandle->sciAHandle);
rxCommandPtr++;
if (rxCommand[rxCommandPtr]=='\n')
{
ifEOFDetected=true;
}
//SCI_write_char(halHandle->sciAHandle, rev_data);
}
SCI_clearRxFifoOvf(halHandle->sciAHandle);
SCI_clearRxFifoInt(halHandle->sciAHandle);
PIE_clearInt(halHandle->pieHandle,PIE_GroupNumber_9); // Acknowledge interrupt from PIE group 9
}
//====================================================
//====================================================SCI Receive Data ISR
// Purpose :
// Input :
// Output :
// Note :
// Status :
//====================================================
void PIE_enableSciInt(PIE_Handle pieHandle,const SCI_IntNumber_e sciType)
{
PIE_Obj *pie = (PIE_Obj *)pieHandle;
uint16_t index = 8; // index is counted from 0, so INT9 has index 8
uint16_t setValue = (1 << sciType);
// set the value
pie->PIEIER_PIEIFR[index].IER |= setValue;
return;
} // end of PIE_enableSciInt() function
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Command
I attached the code