µTasker Forum
µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: kbw on February 20, 2009, 11:47:27 AM
-
Hello,
after commenting out #define DEMO_UART in app_hw_m5223x.h the linker complains
error LNK2019: unresolved external symbol _fnSetNewSerialMode referenced in function _fnComitt_UART usb_application.obj uTasker
I want to have fnDebugMsg to go to Telnet which works and to use the UART for communications.
Therefore in application.c the following lines shoud not be executed (Line 639 to 644) and the Uart kept free for personal use.
#if defined SERIAL_INTERFACE && defined DEMO_UART
if (!fnSetNewSerialMode(FOR_I_O)) {
return;
}
DebugHandle = SerialPortID;
#endif
How can I accomplish this?
Regards
Karl
-
Hi Karl
I am sorry, obviously the combination of USB without demo debug output has no been tested before. [Note that the USB demo includes a USB<->RS232 gateway so it is usual to use it together with the debug output, however there are also 2 other UARTs which could be used for alternative functions too].
To allow this build, you can change the following in usb_application.c:
#ifdef SERIAL_INTERFACE
fnSetNewSerial();
#endif
to
#if defined SERIAL_INTERFACE && defined DEMO_UART
fnSetNewSerial();
#endif
Regards
Mark
-
Hi Mark,
I got it to work now. Debug messages are sent to telnet and the serial ports is sending 'Hello World' every second. The code is puzzled together from code in this forum and the documentation. I have put the code on the M52259DEMO board and it worked too.
Maybe others find it useful as an simple example.
Regards
Karl
// ecrTask.c
/* settings done in other files
//
usb_application.c
=================
//#ifdef SERIAL_INTERFACE
#if defined SERIAL_INTERFACE && defined DEMO_UART // DEMO_UART not used
fnSetNewSerialMode(MODIFY_CONFIG);
#endif
app_hw_m5233x.h
===============
#ifdef SERIAL_INTERFACE
#if defined _M52210 || defined _M52212 || defined _M52213 // {35}
#define NUMBER_SERIAL (2) // the number of physical queue needed for serial interface(s)
#else
#define NUMBER_SERIAL (3) // the number of physical queue needed for serial interface(s)
#endif
#define SERIAL_PORT_0 '1' // <- if we open UART channel 0 we simulate using com1 on the PC
#define SERIAL_PORT_1 '2' // <- if we open UART channel 1 we simulate using com2 on the PC
#define SERIAL_PORT_2 '0' // <- we dont have com3 on the PC
#if defined M52210DEMO || defined M52211EVB
#define DEMO_UART 1 // use UART 1 (the UART connector on the board)
#define PPP_UART 0 // use UART 0 for PPP
#define MODBUS_UART_0 0 // {44}
#else
//#define DEMO_UART 0 // <---------- dont use DEMO_UART
application.c
=============
extern void fnApplication(TTASKTABLE *ptrTaskTable)
{
...
ifdef USE_MAINTENANCE
fnInitialisePorts(); // set up ports as required by the user
#endif
uTaskerStateChange(TASK_DEBUG, UTASKER_ACTIVATE);
//
// Sendig a message to start the task
fnInterruptMessage(KBW_ECR_TASK, WAKE_UP_LITTLE_BABY); // <- Sendig a message to start the task
//
TaskConfig.h
============
#define KBW_ECR_TASK 'e' // Task handling Electronic Cash Register
//
extern void fnECRTask(TTASKTABLE *ptrTaskTable); // This task will communicate with the Electronic Cash Register
//
const UTASK_TASK ctNodes[] = { // we use a single fixed configuration (single node)
DEFAULT_NODE_NUMBER, // configuration our single node
TASK_WATCHDOG, // watchdog task
//
KBW_ECR_TASK,
const UTASKTABLEINIT ctTaskTable[] = {
// task name, task routine, input queue size, start delay, period, initial task state
{ "eCR", fnECRTask, SMALL_QUEUE, (DELAY_LIMIT)( NO_DELAY_RESERVE_MONO ), (DELAY_LIMIT) 0 , UTASKER_STOP}, // ECR task to communicate with serial port 1 to ECR
*/
#include "config.h"
//
#define OWN_TASK KBW_ECR_TASK
#define E_TIMER_PERIODIC 1
#define TASK_PERIOD 0.2 // check every 200 ms
//
//Prototypes
void setUart(unsigned char ucDriverMode);
//
//
// Global variables
static QUEUE_HANDLE SerialPortID; // queuehandler for serialport
//
extern void fnECRTask(TTASKTABLE *ptrTaskTable)
{
//
static int iState = 0;
static char unsigned ucCounter;
QUEUE_HANDLE PortIDInternal = ptrTaskTable->TaskID; // qued ID for task input
unsigned char ucInputMessage[HEADER_LENGTH]; // reserve spave for simple message
//
while (fnRead(PortIDInternal, ucInputMessage, HEADER_LENGTH)){ // check input queue
switch ( ucInputMessage[MSG_SOURCE_TASK]){
case TIMER_EVENT:
if( E_TIMER_PERIODIC == ucInputMessage[MSG_TIMER_EVENT]){
//
fnWrite(SerialPortID, (unsigned char *)"Hello world\n\r", 13);
//
uTaskerMonoTimer(OWN_TASK, (DELAY_LIMIT)(TASK_PERIOD * SEC), E_TIMER_PERIODIC);
}
break;
case INTERRUPT_EVENT:
if(WAKE_UP_LITTLE_BABY == ucInputMessage[MSG_INTERRUPT_EVENT]){
fnDebugMsg("starting task: KBW_ECR_TASK");
//
setUart(FOR_I_O);
iState = 1;
//
uTaskerMonoTimer(OWN_TASK, (DELAY_LIMIT)(TASK_PERIOD * SEC), E_TIMER_PERIODIC);
}
}
}
}
//
void setUart(unsigned char ucDriverMode){
TTYTABLE tInterfaceParameters; // table for passing information to driver
tInterfaceParameters.Channel = 0; // set UART channel 0 (COM1). for serial use
tInterfaceParameters.ucSpeed = temp_pars->temp_parameters.ucSerialSpeed; // baud rate
tInterfaceParameters.Rx_tx_sizes.RxQueueSize = RX_BUFFER_SIZE; // input buffer size
tInterfaceParameters.Rx_tx_sizes.TxQueueSize = TX_BUFFER_SIZE; // output buffer size
tInterfaceParameters.Task_to_wake = OWN_TASK; // wake self when messages have been received
#ifdef SUPPORT_FLOW_HIGH_LOW
tInterfaceParameters.ucFlowHighWater = temp_pars->temp_parameters.ucFlowHigh;// set the flow control high and low water levels in %
tInterfaceParameters.ucFlowLowWater = temp_pars->temp_parameters.ucFlowLow;
#endif
tInterfaceParameters.usConfig = temp_pars->temp_parameters.usSerialMode;
#define TEST_MSG_MODE
#ifdef TEST_MSG_MODE
tInterfaceParameters.usConfig |= (MSG_MODE);
#if defined (TEST_MSG_CNT_MODE) && defined (SUPPORT_MSG_CNT)
tInterfaceParameters.usConfig |= (MSG_MODE_RX_CNT);
#endif
tInterfaceParameters.usConfig &= ~USE_XON_OFF;
tInterfaceParameters.ucMessageTerminator = '\r';
#endif
#ifdef SERIAL_SUPPORT_DMA
tInterfaceParameters.ucDMAConfig = UART_TX_DMA; // activate DMA on transmission
//tInterfaceParameters.ucDMAConfig |= (UART_RX_DMA | UART_RX_DMA_HALF_BUFFER); // test half buffer DMA reception
#endif
fnDebugMsg("\n\rInitialising serial port ");
if ((SerialPortID = fnOpen( TYPE_TTY, ucDriverMode, &tInterfaceParameters )) != 0) { // open or change the channel with defined configurations (initially inactive)
fnDriver( SerialPortID, ( TX_ON | RX_ON ), 0 ); // enable rx and tx
if (tInterfaceParameters.usConfig & RTS_CTS) { // {8}
fnDriver( SerialPortID, (MODIFY_INTERRUPT | ENABLE_CTS_CHANGE), 0 ); // activate CTS interrupt when working with HW flow control (this returns also the present control line states)
fnDriver( SerialPortID, (MODIFY_CONTROL | SET_RTS), 0 ); // activate RTS line when working with HW flow control
}
}
}
-
Hi Karl
I am glad that you managed to puzzle it together and that it is now doing what you want it to do.
Many thanks for the code - I am sure that it will come in handy to new users!!
Good luck
Regards
Mark
PS. Did you also try simulating it all???