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
16
µTasker general / Re: Incorrect PWM frequency
« on: October 01, 2020, 02:36:14 PM »
great, that worked

thank you

17
µTasker general / Incorrect PWM frequency
« on: October 01, 2020, 05:46:19 AM »
Hi,

simple question, I'm trying to generate a PWM signals with 50% duty cycle, between 650kHz-750kHz on a KL03.

For example at 600kHz I use

Code: [Select]
    pwm_setup.pwm_mode = (PWM_SYS_CLK | PWM_PRESCALER_1);
    pwm_setup.pwm_frequency = PWM_TIMER_US_DELAY(TIMER_FREQUENCY_VALUE(650000), 1);
    pwm_setup.pwm_value = _PWM_PERCENT(50, pwm_setup.pwm_frequency);

PWM_SYS_CLK should be 8MHz. But I don't get the right value, my PWM is at 990kHz.
What am I doing wrong?

18
µTasker general / Sleep-receive state machine with timeouts
« on: September 13, 2020, 05:53:13 PM »
Hi,
I'm trying to implement a state machine but I am having issues with the task.
I simply have two states: SLEEP and RX and I want to do

1) stay in SLEEP for T1 sec
2) after T1 sec go to RX
3) stay in RX for T2 sec (if something is received, aka interrupt on a pin, process data)

All these things work independently in my code. But I don't know how to properly activate the task


Code: [Select]
int const SLEEP = 1;
int const RX = 2;

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

case 0 :
steupIinterruptHandler();

iState = 1;
uTaskerMonoTimer('C', (DELAY_LIMIT) (0.5 * SEC), UTASKER_ACTIVATE);
break;

case SLEEP :

deactivate_data_processing();

// do sleep operations here

iState = RX;
uTaskerMonoTimer('C', (DELAY_LIMIT) (T1 * SEC), UTASKER_ACTIVATE);
break;

case RX :
activate_data_processing();

//if received interrupt, process data

iState = SLEEP;
uTaskerMonoTimer('C', (DELAY_LIMIT) (T2 * SEC), UTASKER_ACTIVATE);
break;
}
}

My major problem is that the interrupt is not triggered (it normally works). If I can suspend/resume the whole task that's fine too, but I don't know how to do it

19
µTasker general / Re: SPI configs increases current absorption of 70mA
« on: August 25, 2020, 05:32:30 PM »
A slightly unrelated question.

_CONFIG_PERIPHERAL(B, 0, PB_0_SPI0_SCK) defines the CLK pin. For the KL03, the family manual says that PB_0, PA_9 or PB_11 can be used as clock lines (depending on the chip).

I am assuming that if I want the clock on PA_9, then I need to do:
_CONFIG_PERIPHERAL(A, 9, PA_9_SPI0_SCK);

and add:

#define PA_09_SPI0_SCK PORT_MUX_ALT3, as PA_09_SPI0_SCK is not defined in the code.

Does it sound correct?

But, I can't use a generic GPIO pin for the CLK, like PA_8, can I?

20
µTasker general / Re: SPI configs increases current absorption of 70mA
« on: August 21, 2020, 04:38:47 PM »
Fantastic, Mark!

I tried the lines 1 by 1 and I found out that the issue was the clock. It interfered with the clock of the device it is connected to, as the other device can be master or slave but I hadn't configured it as slave.

Great,
thanks

21
µTasker general / Re: SPI configs increases current absorption of 70mA
« on: August 19, 2020, 12:05:36 AM »
Thanks  Mark,

so the problem seems to be caused by SPI0_C1 = (SPI_C1_CPHA | SPI_C1_CPOL | SPI_C1_MSTR | SPI_C1_SPE); if I remove this line the current consumption stays at 3mA.
Now you see I have two chip selects, if SPI0_C1 = (SPI_C1_CPHA | SPI_C1_CPOL | SPI_C1_MSTR | SPI_C1_SPE);  is there and I only use the first chip select, the current is 47mA. If I add the second chip select the current goes up to 80mA. If I keep both chip selects but remove SPI0_C1 = (SPI_C1_CPHA | SPI_C1_CPOL | SPI_C1_MSTR | SPI_C1_SPE);, as I said, the current goes back to 3mA

22
µTasker general / SPI configs increases current absorption of 70mA
« on: August 18, 2020, 09:13:48 PM »
Hi,
I'm programming a KL03. My code has PWM, UART and a couple of interrupts. It is up and running and it only absorbs 2-3mA.
When I configure the SPI the absorbed current jumps to 75-80mA. Is this normal? Can I somehow reduce it? Even configuring and deconfiguring the SPI interface would be an acceptable solution since I use it rarely.

This is my config, just regular SPI:

Code: [Select]
#define INITIALISE_SPI_SD_INTERFACE()  POWER_UP(4, SIM_SCGC4_SPI0); \
                        _CONFIG_PERIPHERAL(B, 0, PB_0_SPI0_SCK); \
_CONFIG_PERIPHERAL(A, 7, (PA_7_SPI0_MOSI | PORT_SRE_FAST | PORT_DSE_HIGH)); \
_CONFIG_PERIPHERAL(A, 6, (PA_6_SPI0_MISO | PORT_PS_UP_ENABLE)); \
_CONFIG_DRIVE_PORT_OUTPUT_VALUE(A, SPI_CS1, SPI_CS1, (PORT_SRE_FAST | PORT_DSE_HIGH));\
_CONFIG_DRIVE_PORT_OUTPUT_VALUE(A, SPI_CS2, SPI_CS2, (PORT_SRE_FAST | PORT_DSE_HIGH));\
SPI0_C1 = (SPI_C1_CPHA | SPI_C1_CPOL | SPI_C1_MSTR | SPI_C1_SPE); \
SPI0_BR = (SPI_BR_SPPR_PRE_4 | SPI_BR_SPR_DIV_2); \
(void)SPI0_S; (void)SPI0_D;

I tried POWER_UP(4, SIM_SCGC4_SPI0) and POWER_DOWN(4, SIM_SCGC4_SPI0) and that reduces the current to half. How can I deconfigure the other peripherals _CONFIG_PERIPHERAL and _CONFIG_DRIVE_PORT_OUTPUT_VALUE?

23
µTasker general / UART Tx bytes are shifted
« on: August 16, 2020, 03:04:09 AM »
Hi,

I'm having a small issue with UART on a KL03.
By default the UART clock is LPUART_IRC48M                                       

Code: [Select]
        #define LPUART_IRC48M                                            // if the 48MHz clock is available clock the LPUART from it
      //#define LPUART_OSCERCLK                                          // clock the LPUART from the external clock
      //#define LPUART_MCGIRCLK                                          // clock the LPUART from MCGIRCLK (IRC8M/FCRDIV/LIRC_DIV2) - default if others are not defined

Now if I comment LPUART_IRC48M and uncomment #define LPUART_MCGIRCLK it happens that when I transmit, my characters are wrong. Basically, the transmitted bytes are shifted of 0x60
So for example, if I want to transit "A" (0x41), instead of an "A", UART transmits 0xA1 (which is 0x41 + 0x60).

What am I doing wrong? How can I fix this?
Thank you

24
µTasker general / Re: output the system CLK
« on: June 26, 2020, 07:06:36 PM »
That worked easily, thanks.

A few quick questions:

1) where is SLOW_CLOCK_DIVIDE used?

2) Can I generate a PWM using the PWM_INTERRUPT_SETUP  but in low power mode (32kHz clock) instead of using the 48MHz?
3) Does low power mode still supports SPI?
4) Can I actually "shut down" the 48MHz clock source?

My goal is to generate a PWM with the lowest power possible and sometimes use SPI.

25
µTasker general / output the system CLK
« on: June 19, 2020, 11:08:26 PM »
Hi,
simple question, how can I output the system clock on the KL03? Also I am assuming that I can only use PTA4 and PTA12 since they are the only two that have an ALT function called CLKOUT, right?

26
µTasker general / Re: Momentarily disable interrupt routine
« on: May 29, 2020, 08:41:58 PM »
I had notifications off for this post.

Always very helpful Mark

27
Mark

is there a way to flush the Tx/Rx UART buffers?

28
thanks Mark.

I'll check that.
Since I define my own interface, which task or function could be echoing the characters? application.c does this but I don't call the task. Can I uncomment the fnEchoInput somewhere?

29
Hi,
I setup a UART interface on a kinetis KL03 to Tx an Rx. The device can both receive and transmit. But I'm having a problem. Every time I receive a message, the device also sends back a sequence of 0x17 or 0x11 with some 0x19?
These seem to be control commands but I am not sure why, and if there is any way to remove them

Thank you

30
µTasker general / Momentarily disable interrupt routine
« on: May 17, 2020, 04:23:02 PM »
Hi,
is it possible to momentarily disable an interrupt? Or its handler?

I mean, I configure the interrupt

Code: [Select]
INTERRUPT_SETUP interrupt_setup;
interrupt_setup.int_type       = PORT_INTERRUPT;                    // identifier to configure port interrupt
interrupt_setup.int_handler    = fn_my_interrupt_handler;           // 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  = INTERRUPT_PIN;           // the IRQ input connected
interrupt_setup.int_port_sense = (IRQ_RISING_EDGE | PULLUP_ON);  // interrupt is to be falling edge sensitive
fnConfigureInterrupt((void *)&interrupt_setup);

Then at some point I want to suspend handling the interrupt and then activate it again. Something like this:


Code: [Select]
suspend_interrupt();
function();
reactivate_interrupt();

Is it possible?

Pages: 1 [2] 3 4 5