How to access Processor Expert data structures - Hit any key to continue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to access Processor Expert data structures - Hit any key to continue

801 Views
marks
Contributor IV

Hello. I'm using the ConsoleIO component under CPU External Devices->Display in Processor Expert to do terminal IO. Works great! Using printf() and getchar() to create a menu of tests. But now I want to have a while() loop run and have the loop stop on "any key". I have seen functions like uart_getchar_present(TERM_PORT) in other demo code but this function is not available using the ConsoleIO component. So how do I break a while() loop upon a uart character received?

I have another question. How do I access Processor Expert data structures? For example, when trying to figure out how to detect if a keyboard character is received I came across this structure in IO1.h:

/*! Device data structure type */

typedef struct {

  uint16_t SerFlag;                    /*!< Flags for serial communication */

  uint16_t InpRecvDataNum;     /*!< The counter of received characters */

  uint8_t *InpDataPtr;                /*!< The buffer pointer for received characters */

  uint16_t InpDataNumReq;       /*!< The counter of characters to receive by ReceiveBlock() */

  uint16_t OutSentDataNum;     /*!< The counter of sent characters */

  uint8_t *OutDataPtr;               /*!< The buffer pointer for data to be transmitted */

  uint16_t OutDataNumReq;      /*!< The counter of characters to be send by SendBlock() */

  LDD_TUserData *UserDataPtr;  /*!< Pointer to user data */

} IO1_TDeviceData;

typedef IO1_TDeviceData *IO1_TDeviceDataPtr ; /*!< Pointer to the device data structure. */

Obviously I am not a firmware designer or I would know this stuff. I'm a hardware engineer trying to figure this out.

Seems like if I could read InpRecvDataNum and see if it changes then I would know that a character was received.

Whether or not this is the right approach for the "hit any key" question I would still like to understand how to access the data in this structure. I know that a pointer to this structure is returned by the IO1_init(). And searching on IO1_init I find this (I cut out the code in the middle):

LDD_TDeviceData* IO1_Init(LDD_TUserData *UserDataPtr)

{

  /* Allocate device structure */

  IO1_TDeviceDataPtr DeviceDataPrv;

blah, blah, blah....

/* Registration of the device structure */

  PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_IO1_ID,DeviceDataPrv);

  return ((LDD_TDeviceData *)DeviceDataPrv);

}

So LDD_TDeviceData must be a pointer to the data structure right? But the trouble is that there are a whole bunch of these.

Seems like this:

#include "IO1.h"

uint16_t anyData;

anyData = DeviceDataPrv->InpDataNum;

or this

#include "IO1.h"

uint16_t anyData;

anyData = DeviceDataPrv.InpDataNum;

should work but it does not compile. I get an error that DeviceDataPrv is undefined . Any insight to both questions would be greatly appreciated !!

Thanks in advance.

Mark

0 Kudos
2 Replies

466 Views
adriancano
NXP Employee
NXP Employee

Hi,

The Console IO component is a High level component, this means that the component only includes basic functionality of the modules; in this case this Console IO is using the UART peripheral of the MCU. You can see this when you add the console component and this one add another inherited component at the time which is Serial_LDD component.

console component.jpg

For your application, where you need to read the received bytes using interrupt or polling methods, I recommend to use the Serial_LDD component that you can select from the Components Library. With this LDD component you will be able to use more functions of the UART peripheral.

Please check the attached Component user guide of the Serial_LDD component. There you can find information of the methods and a typical usage code. This document is available on the KDS installation folder following the path: <install_folder>\KDS_version_number\eclipse\ProcessorExpert\Help\ComponentUserGuides.


Hope this information can help you.

:smileyinfo:Remember posting your questions in a dedicated space, for example Kinetis Microcontrollers there it will have more visibility.

Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

466 Views
marks
Contributor IV

Hi Adrian, Thank you for the fast response! I am already using the Serial_LDD component you mentioned. It comes with the ConsoleIO component exactly as you have shown. I tried several things but no luck.

I tried the approach shown in the "Typical Usage" section but no luck.

I gave up on using the LDD method approach and  I just checked the "Receiver Data Register Full" flag in UART0_S1 and that works. Here's my solution:

while(!(0x10 & UART0_S1)) { // hit any key to exit loop 

printf("  Hello World!");

}

I would like to understand how to use LDDs in my code. I would also like to understand how to access the data structure associated with every LDD.

Seems like everything is all about structures and pointers. .

Thank you for the component user guide. If you can think of any other documents that might help please attach.

Best regards,

Mark

0 Kudos