Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Raffaele

Pages: 1 2 3 [4] 5
46
µTasker general / Re: UART Tx/Rx in different pins for KL03
« on: January 09, 2020, 01:15:06 AM »
thanks Mark,

I'm not trying to configure two Rx or two Tx pins. Still one Tx and one Rx but not on the default ports. Would that work?
I am not sure if I properly defined the function that is activated when bytes are received. As reported in my first part, I wake my own task Task_to_wake = MY_UART_TASK that calls a function that should read the UART.

I also tried to read the UART, using fnRead(SerialPortIDRx, rxMsg, 1); periodically instead of waiting for data but it looks like there are no bytes in on the UART. It could also be that I am not enabling some necessary defines or configs

47
µTasker general / UART Tx/Rx in different pins for KL03
« on: January 09, 2020, 12:24:09 AM »
Hi,
is it possible to set up the LPUART Tx and Rx on two different pins in the KL03? I tried something like the following code, I can transfer but not receive. I don't know if my receive routine is correct:


Code: [Select]
#include "config.h"

#define SET_UART_PORT() _CONFIG_PERIPHERAL(B, 3,  (PB_3_LPUART0_TX | UART_PULL_UPS ));\
_CONFIG_PERIPHERAL(B, 1,  (PB_1_LPUART0_RX | UART_PULL_UPS ));


#define SERIAL_INTERFACE

static int iState = 0;

static void fn_process_data() {
         unsigned char ucInputByte;
while (fnRead( SerialPortID, &ucInputByte, 1) != 0) {
while (ucInputByte--) {
fnDebugMsg("\r\n");
fnDebugDec(ucInputByte, 0);
}
}
}


extern void fnTaskMyUartToSPI(TTASKTABLE *ptrTaskTable) {
switch (iState) {

case 0 :

SET_UART_PORT();

TTYTABLE tInterfaceParameters; // table for passing information to driver
QUEUE_HANDLE SerialPortID; // UART handle to be obtained during open
tInterfaceParameters.Channel = 0; // set UART channel for serial use
tInterfaceParameters.ucSpeed = SERIAL_BAUD_115200;
tInterfaceParameters.Rx_tx_sizes.RxQueueSize = 256; // input buffer size
tInterfaceParameters.Rx_tx_sizes.TxQueueSize = 512; // output buffer size
tInterfaceParameters.Task_to_wake = TASK_MY_UART_TO_SPI; // wake task on rx
#ifdef SUPPORT_FLOW_HIGH_LOW
tInterfaceParameters.ucFlowHighWater = 80; // set the flow control high in %
    tInterfaceParameters.ucFlowLowWater = 20; // set the flow control low in %
#endif
tInterfaceParameters.Config = (CHAR_8 + NO_PARITY + ONE_STOP +  CHAR_MODE);

if ((SerialPortID = fnOpen( TYPE_TTY, FOR_I_O, &tInterfaceParameters)) != 0) {
// open the channel with defined configurations (initially inactive)
fnDriver(SerialPortID, ( TX_ON | RX_ON ), 0); // enable rx and tx
}

DebugHandle = SerialPortID;

iState = 1;
break;


case 1 :
fn_process_data();
break;
}
}


48
µTasker general / Re: Task executed only once and then from interrupt
« on: January 04, 2020, 08:54:34 PM »
Verify also that SUPPORT_PORT_INTERRUPTS is enabled so that the port interrupt driver is present.

Great, this was part of the problem.
Also my code works on a KL03 20-pin WLCSP, but didn't fully work on the FRDM-LK03Z.
But essentially this solved my issue.

Thank you again Mark :)

49
µTasker general / Re: Task executed only once and then from interrupt
« on: January 04, 2020, 05:36:39 PM »
The microcontroller is the KL03 so the Cortex M0+

50
µTasker general / Re: Task executed only once and then from interrupt
« on: January 04, 2020, 04:08:20 AM »
ok I was able to fix the problem. The only thing now is that my handler function doesn't get called. I was expecting that whenever a FALLING_EDGE signal is on PTB4 the function fn_my_interrupt should be called but nothing happens

51
µTasker general / Re: Task executed only once and then from interrupt
« on: January 03, 2020, 05:57:01 PM »
I've been doing few tests, unless there is something wrong in my code, it looks like there is a reset every second. In fact the static or global iState variable switches between 0 and 1 every  (DELAY_LIMIT)(0.5 * SEC)

52
µTasker general / Re: Task executed only once and then from interrupt
« on: January 03, 2020, 05:23:29 AM »
Thank you Mark,
that is the behavior I was expecting in fact. And the watchdog is disabled, but there is something that every second retriggers it
I use the command {"r", fnTaskMyInterrupt, NO_QUE,  (DELAY_LIMIT)(0.5 * SEC), UTASKER_STOP}, in TaskConfig to execute the task the first time. I tried other variations (UTASKER_GO etc) but no much luck

53
µTasker general / Task executed only once and then from interrupt
« on: January 03, 2020, 01:59:27 AM »
Hi I have a task that should be executed once (to set up some pins and variables) and then executed based on an external interrupt. However the task is executed periodically and every time it repeats the set-up. Basically, the if (iState) is entered periodically and the OUTPUT_PIN doesn't stay low but goes high between executions


#include "config.h"

#define OUTPUT_PIN              PORTB_BIT5
#define SETUP_PIN()  _CONFIG_DRIVE_PORT_OUTPUT_VALUE(B, OUTPUT_PIN, OUTPUT_PIN, (PORT_SRE_FAST | PORT_DSE_LOW));
#define SET_PIN_LOW()      _CLEARBITS(B, OUTPUT_PIN)
#define SET_PIN_HIGH()     _SETBITS(B, OUTPUT_PIN)   

static int iState = 0;

static void fn_my_interrupt(void)
{
   fnInterruptMessage(TASK_MY_INTERRUPT, 141);
}



extern void fnTaskMyInterrupt(TTASKTABLE *ptrTaskTable) {

   QUEUE_HANDLE PortIDInternal = ptrTaskTable->TaskID;
   unsigned char ucInputMessage[MEDIUM_MESSAGE];
   
   if (!iState) {
      SETUP_PIN();
      SET_PIN_LOW();
      
            INTERRUPT_SETUP interrupt_setup;                                     // interrupt configuration parameters
       interrupt_setup.int_type       = PORT_INTERRUPT;                     // identifier to configure port interrupt
       interrupt_setup.int_handler    = fn_my_interrupt;                    // handling function
       interrupt_setup.int_priority   = PRIORITY_PORT_B_INT;                 // interrupt priority level
       interrupt_setup.int_port       = PORTB;                 // the port that the interrupt input is on
       interrupt_setup.int_port_bits  = PORTB_BIT4;                      // the IRQ input connected
       interrupt_setup.int_port_sense = IRQ_FALLING_EDGE ;// | PULLUP_ON);     // interrupt is to be falling edge sensitive
       fnConfigureInterrupt((void *)&interrupt_setup);
       iState = 1;
       //uTaskerStateChange(TASK_MY_INTERRUPT, UTASKER_SUSPENDED);
   }


   while (fnRead( PortIDInternal, ucInputMessage, HEADER_LENGTH)) {
      switch (ucInputMessage[MSG_SOURCE_TASK]) {
      case 141 :
         // YOUR CODE HERE //
         SET_PIN_HIGH();
      break;
      }
      break;
      }
}




54
µTasker general / uTasker V1.4.11 KDS Studio compile error FreeRTOS folder
« on: December 22, 2019, 11:24:38 PM »
Hi all,
anyone experiencing problems with last uTasker V1.4.11 code? I downloaded it from the GIT, followed the instructions of the video https://www.youtube.com/watch?v=K8ScSgpgQ6M as usual, but the compiling fails.

 I have an error at \uTasker-Kinetis-master\FreeRTOS\Source\portable\RVDS\ARM_CM4_MPU\port.c
 #include "FreeRTOS.h"  <- fatal error: FreeRTOS.h: no such file or directory

55
Nice, thanks a lot! Very helpful

56
Thank you Mark, SPI and UART work well, but I need to have the wdog active. Any ideas why?

One more question, is there a process that is executed every 50ms? Could it be  something like a timer to keep track of when my task (that is executed periodically) has to be re-executed?  The reason I am asking is because I have the KL03 on a custom PCB and I can see that every 50ms there is a signal like a spike leaking from the device and interfering with other components, but I am not sure if it is routed internally or it goes to a pin.
If I disable my task I don't see it any more, so I thought it was a tick

Thanks again

57
Hi,
I need a minimal code for the KL03 that defines an SPI master interface using the ALT3 pin configuration (B0 CLK, A3 MOSI, A5 SS, A6 MISO) and prints the result on UART. I want to disable everything that is not necessary.
Few questions:

1) Do I need to comment some of the functions in TaskConfig.h? I commented the wdog and app but apparently they are needed (?) otherwise I can't print to UART
2) I assume, I might be wrong though, that the SPI ALT3 configuration is already defined, but how do I enable the ALT3 instead of the default SPI, and where do I change the parameters (CLK etc)?
3) What function do I need to call to actually enable SPI?

I read this http://www.utasker.com/forum/index.php?topic=1902.0 so I know how to set up the SPI interface but  in app_hw_kinetis.h I can't find the INITIALISE_SPI_SD_INTERFACE() for the KL03

Thank you

58
NXPTM M522XX, KINETIS and i.MX RT / [Kinetis KL03] Print timestamp
« on: January 16, 2019, 03:41:41 AM »
Hi,
I'm looking for a simple way to print a timestamp via UART, or the time elapsed between two events. The code that I have is normally working. I tried the function time() (I included time.h from the C standard libraries), the building doesn't give errors but the .bin file is not generated.
What I did was simply

#include <time.h>
...
time_t now = time(NULL);


The function time(NULL) is creating the issue.
Any suggestion?

Thank you

59
NXPTM M522XX, KINETIS and i.MX RT / [Kinetis KL03] Custom pin assignments
« on: November 26, 2018, 07:52:36 PM »
Hi all,

on page 48 of the Kinetis KL03 datasheet https://www.nxp.com/docs/en/data-sheet/KL03P24M48SF0.pdf   the signals available on each pin are reported.

My question is: can I change this assignments?
Let's say I want to assign a timer TPM0_CH0 to PTB4 as ALT2 function. Now, ALT2 function is already assigned to PTB4 and it is an I2C0_SDA. Or I could also assign TPM0_CH0 as ALT4 since it is empty.

I know how to use the _CONFIG_PERIPHERAL to select the function that I want on a pre-assigned pin, but I don't know IF/HOW to reassign functions to a pin.
If this is possible, which function/registers do I need to change? And in which file are they?

Thank you

60
NXPTM M522XX, KINETIS and i.MX RT / Re: SP7 and ADC
« on: June 03, 2018, 02:28:06 PM »
Hi

ADC interrupts are most useful when monitoring trigger levels, zero crossings or external SYNC started scans. To simply read a value no interrupts need to be activated, instead the conversion can be started (or left running in free-run mode) and simply read the value whenever required.

There are some examples of using the ADC interface in the demo project as follows:
"ADC: enable HW support using SUPPORT_ADC in app_hw_m5223x.h and the demo TEST_ADC in application.c. This will show the module being configured to generate interrupts when the input signal leaves a defined voltage range. A second input will be configired with an offset and interrupt on zero-crossing. The code can be changed (using examples there) to test differential inputs and the use of the SYNC to activate a conversion scan with interrupt on completion."

To configure a free-running ADC on channel 0 without interrupt do the following:

Code: [Select]
static void fnConfigureADC(void)
{
    ADC_SETUP adc_setup;                                                 // interrupt configuration parameters
    adc_setup.int_type = ADC_INTERRUPT;                                  // identifier when configuring
    adc_setup.int_adc_bit = 0;                                           // ADC channel 0
    adc_setup.int_adc_mode = (ADC_CONFIGURE_ADC | ADC_CONFIGURE_CHANNEL | ADC_SEQUENTIAL_MODE | ADC_SINGLE_ENDED | ADC_LOOP_MODE | ADC_START_OPERATION); // single ended configuration in loop mode
    adc_setup.int_adc_speed = (unsigned char)(BUS_CLOCK/5000000);        // 5MHz sampling (must be between 100kHz and 5MHz)
    adc_setup.int_adc_int_type = 0;                                      // no interrupt
    fnConfigureInterrupt((void *)&adc_setup);                            // configure and start operation
}

To subsequently read the present sample:

Code: [Select]
static void fnReadRes(void)
{
    ADC_SETUP adc_setup;                                                 // interrupt configuration parameters
    ADC_RESULTS results;
    adc_setup.int_type = ADC_INTERRUPT;                                  // identifier when configuring
    adc_setup.int_adc_bit = 0;
    adc_setup.int_adc_result = &results;
    adc_setup.int_adc_mode = (ADC_READ_ONLY | ADC_GET_RESULT);
    fnConfigureInterrupt((void *)&adc_setup);                            // get result

    if (results.ucADC_status[0] != ADC_RESULT_NOT_READY) {
      //results.sADC_value[0];                                           // result here
    }
}


This is a bit of overkill to read just a single register and can of course be performed by direct register accesses if required:
ADC_ADSTAT contains the status of the ADC (the RDY_CHANNEL0 should be set) and the result is in ADC_ADRSLT0.

If you configure multiple channels the parameter ADC_ALL_RESULTS will return all channel values in ADC_RESULTS results.

Regards

Mark
Hi,
doesn't the ADC need a calibration? Is it in this piece of code, or is it done somewhere else?

Thank you

Pages: 1 2 3 [4] 5