What is wrong with the following picture??? It spits out "Hello World" but never receives any of my typing to echo!
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
static unsigned char bUARTdebugInputCount = 0 ;
LDD_TDeviceData * pUARTdebugDeviceDataStructure ;
char strHelloWorld[] = "Hello, World!\r\nLEDsAsynchroSerial here!\r\n" ;
byte bReceivedByte ;
unsigned uCharsInRxBuf ;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
/* Write your code here */
pUARTdebugDeviceDataStructure = ASerialLdd1_Init( NULL );
ASerialLdd1_SendBlock( pUARTdebugDeviceDataStructure, strHelloWorld, sizeof( strHelloWorld ) ) ;
for(;;) {
while( ( uCharsInRxBuf = UARTdebug_GetCharsInRxBuf() ) > 0 ) {
++bUARTdebugInputCount ;
UARTdebug_RecvChar( &bReceivedByte ) ;
UARTdebug_SendChar( bReceivedByte ) ;
}
}
While waiting for help, I'm tracing code to see if I can figure it out myself ...
Following examples and documentation and help as best I could, I coded the line ...
pUARTdebugDeviceDataStructure = ASerialLdd1_Init( NULL );
... not least because I needed that pointer-to-structure initialized to use on the next line for the SendBlock call.
BUT!
I am very surprised to find, in Cpu.c/void PE_low_level_init(void) ...
{
[...]
/* ### Asynchro serial "UARTdebug" init code ... */
UARTdebug_Init();
__EI();
}
... and in void UARTdebug_Init(void) ...
{
[...]
ASerialLdd1_DeviceDataPtr = ASerialLdd1_Init(NULL); /* Calling init method of the inherited component */
HWEnDi(); /* Enable/disable device according to status flags */
}
In other words, I'm calling ASerialLdd1_Init() but PEx Generatded_Code is calling ASerialLdd1_Init(), too?
That doesn't seem right; is it?
Hi,
I assume you are using the AsynchroSerial component. This one inherits Serial_LDD component and uses it as an interface to the hardware – the AsynchroSerial component on Kinetis families is rather SW wrapper to support migration from families where LDD components were not supported.
I’m not very familiar with serial communication drivers, however from the code snippet you posted it looks like you are using both Serial_LDD and AsynchroSerial methods at the same time – I guess this is source of your problems. You have to use either the AsynchroSerial component and its API or the Serial_LDD component (without the AsynchroSerial) and its API – it is not possible to use both of them for the same UART device.
Lukas
This is a tough way to learn Processor Expert -- after-the-fact do-over, after I got it working "the wrong way"!
All I know so far is, there is a list of components in the right-hand panel of eclipse, and none of them are marked "deprecated" or "API" or "wrapper" or "migration". So how are we to know -- before we waste time on the wrong ones -- which are the recommended components for application development, and which are "dependent" components that get pulled in automatically, and which are "legacy" components not recommended for new projects?
I agree that the selection of the right component can be confusing for non-experienced Processor Expert users.
We are planning improvements in the component library and its documentation to ease this task.
best regards
Petr Hradsky
Processor Expert Support Team