S32K144 Touch Pads without FreeMASTER function

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

S32K144 Touch Pads without FreeMASTER function

1,466 Views
alstlr926
Contributor III

Hi, I am trying to implement touch function using S32K144 EVB.
I have an example file for implementing touch functions, but I have a question.
Annotating FMSTR_Poll(); from Main(); does not properly realize the touch function.
FMSTR_Poll() is a function of the FreeMASTER, so I don't know how it affects the implementation of the touch function.
I tried to analyze the FMSTR_Poll() function but failed to get the correct answer.
How can I implement touch function without a FreeMASTER?

Src is as follows.

/****************************************************************************//*!
*
* @file main.c
*
* @version 1.0.0.0
*
* @date January-2017
*
* @brief Touch sense main for S32K144EVB Q100
*
*******************************************************************************/

/*******************************************************************************
* Includes
*******************************************************************************/
#include "S32K144.h"
#include "main.h"
#include "scg.h"
#include "timer.h"
#include "adc.h"
#include "pcc.h"
#include "lpuart.h"
#include "freemaster.h"
#include "ets.h"
#include "power_mode.h"

/*******************************************************************************
* Variables
******************************************************************************/
extern uint8_t electrodeTouchQualified[NUMBER_OF_ELECTRODES];
uint8_t clockMode;

// Low power mode
extern uint8_t lowPowerModeCtrl, lowPowerModeEnable;


/*****************************************************************************
*
* Function: void NVIC_Init(void)
*
* Description: Init NVIC
*
*****************************************************************************/
void NVIC_Init(void)
{
// Enable LPTMR0 interrupts in NVIC
NVIC_IRQ_ENABLE(LPTMR0_IRQn);
}

/*****************************************************************************
*
* Function: void GPIO_Init(void)
*
* Description: Init GPIO
*
*****************************************************************************/
void GPIO_Init(void)
{
#ifdef DEBUG_ELECTRODE_SENSE
// Configure as GPIO pin
DES_PORT->PCR[DES_PIN] = PORT_PCR_MUX(1);
// Drive GPIO high
BITBAND_ACCESS32(&(DES_GPIO)->PSOR,DES_PIN) = 1;
// Configure as an output
BITBAND_ACCESS32(&(DES_GPIO)->PDDR,DES_PIN) = 1;

#endif

#ifdef DEBUG_ALGORITHM
// Configure as GPIO pin
DA_PORT->PCR[DA_PIN] = PORT_PCR_MUX(1);
// Drive GPIO high
BITBAND_ACCESS32(&DA_GPIO->PSOR,DA_PIN) = 1;
// Configure as an output
BITBAND_ACCESS32(&DA_GPIO->PDDR,DA_PIN) = 1;
#endif


#if(LOW_POWER_MODE == LPM_DISABLE)
// LPUART1 pins
// PTC6, UART1_RX
PORTC->PCR[6] = PORT_PCR_MUX(0x2);
// PTC7, UART1_TX
PORTC->PCR[7] = PORT_PCR_MUX(0x2);
#endif

// PTD0, RGB LED BLUE
// PTD0 GPIO pin
PORTD->PCR[0] = 0x01000140;
// Turn OFF LED
BITBAND_ACCESS32(&PTD->PSOR,0) = 1;
// PTD0 configured as output
BITBAND_ACCESS32(&PTD->PDDR,0) = 1;

// PTD15, RGB LED RED
// PTD15 GPIO pin
PORTD->PCR[15] = PORT_PCR_MUX(1);
// Turn OFF LED
BITBAND_ACCESS32(&PTD->PSOR,15) = 1;
// PTD15 configured as output
BITBAND_ACCESS32(&PTD->PDDR,15) = 1;

// PTD16, RGB LED GREEN
// PTD16 GPIO pin
PORTD->PCR[16] = PORT_PCR_MUX(1);
// Turn OFF LED
BITBAND_ACCESS32(&PTD->PSOR,16) = 1;
// PTD16 configured as output
BITBAND_ACCESS32(&PTD->PDDR,16) = 1;
}

/*****************************************************************************
*
* Function: void RGBLED_Ctrl(void)
*
* Description: Display touch event
*
*****************************************************************************/
void RGBLED_Ctrl(void)
{
#ifdef ELEC0
// Electrode 0, RED LED
if (electrodeTouchQualified[0] == 1)
{
// Turn ON LED
BITBAND_ACCESS32(&PTD->PCOR,15) = 1;
}
else
{
// Turn OFF LED
BITBAND_ACCESS32(&PTD->PSOR,15) = 1;
}
#endif

#ifdef ELEC1
// Electrode 1, GREEN LED
if (electrodeTouchQualified[1] == 1)
{
// Turn ON LED
BITBAND_ACCESS32(&PTD->PCOR,16) = 1;
}
else
{
// Turn OFF LED
BITBAND_ACCESS32(&PTD->PSOR,16) = 1;
}
#endif
}

/*****************************************************************************
*
* Function: void main(void)
*
* Description: Main routine
*
*****************************************************************************/
void main(void)
{
// Set clock mode
clockMode = RUN_FIRC;

// System clock generator init
SCG_Init(clockMode);

// Peripheral clock enable
PCC_Init(clockMode);

// Flash and enable I/D cache and write buffer
LMEM->PCCCR = LMEM_PCCCR_GO_MASK | LMEM_PCCCR_INVW1_MASK | \
LMEM_PCCCR_INVW0_MASK | LMEM_PCCCR_ENCACHE_MASK;

// Wake-up timer init
LPTMR0_Init(LPTMR_ELEC_CAL);

// ADC0 init (sample time, samples number to average)
ADC0_Init(2, 0, clockMode);

// GPIO init
GPIO_Init();

// Low power mode control disabled
lowPowerModeCtrl = OFF;

#if(LOW_POWER_MODE == LPM_DISABLE)
// Init FreeMASTER UART1
LPUART1_Init(clockMode);

// Init FreeMASTER, poll driven
FMSTR_Init();

// Disable low power mode
lowPowerModeEnable = NO;
#else
// Enable low power mode
lowPowerModeEnable = YES;
#endif

// Init electrode touch sense
electrodeTouchSenseInit();

// Init NVIC
NVIC_Init();

// Enable interrupts
EnableInterrupts;

// Loop forever
while(1)
{
// Control RGB LED
RGBLED_Ctrl();

// Enable FreeMASTER poll, when low power mode disabled
if (lowPowerModeEnable == NO)
{
FMSTR_Poll();              
}

// Run low power mode?
if ((lowPowerModeCtrl == ON) && (lowPowerModeEnable == YES))
{
// S32K144EVB Q100 board
// RUN_FIRC mode typ. 20mA
// VLPS static mode typ. 30uA
// Average current 60uA, (cycling from RUN to VLPS, LPTMR 25ms period, compiler optimized none -O3)
Run_to_VLPS();
}
}
}

Tags (1)
1 Reply

1,274 Views
iulian_stan
NXP Employee
NXP Employee

Hi alstlr926@naver.com‌,

Sorry for the late reply. In case you are interested in the touch-sense functionality only (without FreeMASTER), I would recommend checking the SDK examples first. File→New→S32DS Project from Example:

Capture.PNG

Please note this space is meant for FreeMASTER issues, in case you have platform or SDK specific issues you can address them in the corresponding spaces: S32K or S32 SDK.

Reagards,

Iulian