Recent discussions
I just started using SK-FM4-216-ETHERNET Evaluation Board and it comes with a few examples but I'm looking for the most basic, to understand the use of inputs and outputs, press a button and turn an LED things like that.
Is there any sample code that explain the use of GPIO's?
The software I'm using is Keil uVision 5
Show LessI have just posted this code for your reference.
[Overview]
This code is based on a " UART2 sample code for TLE984x" sample code which I posted it before.
This sample code is simply get all ADC2 data and then show both 8bit hex data and unit-converted values.
So, you can see Central temperature and LS module temperature, too.
This code has three functions as the below.
Key=1: VDDEXT_LED = On
Key=2: VDDEXT_LED = Off
Key=3: Show ADC2 data (Ch0~Ch6)
Each function can execute by key input via terminal software on your PC.
For example, If you type [1] key then VDDEXT_LED will be turn on.
[Environment]
Confirmed evaluation boards :
1) TLE984x Evalboard ( J16 = JP27 = JP28 = Short)
2) TLE9844-2QX Application Kit
IDE :
1)uVision V5.36.0.0
Software :
1) UART2_TTY_EXAMPLE_TLE984x_ADC2.zip
[Execution image]
The following screenshot shows the user pressing the "3" key after RESET.
[Question]
If anybody know about the below, please advise me.
It seems, there is a case where ADC2/Ch1(VDDEXT) value may doesn’t match the VDDEXT-pin voltage.
1) After reset, VDDEXT_ENABLE=0. And both ADC2/Ch1(VDDEXT) value and VDDEXT-pin voltage are 0v.
2) If you set VDDEXT_ENABLE=1(Key=1), then both ADC2/Ch1(VDDEXT) value and VDDEXT-pin voltage are 5v.
3) After that, if you clear VDDEXT_ENABLE=0(Key=2), then ADC2/Ch1(VDDEXT) value is remain 5V while VDDECT-pin voltage is 0V. This is a strange phenomenon, I think.
If I have any misunderstanding about ADC2 module/functions or if there is mistake in my code, please let me know.
Thank you very much in advance.
Show LessAll,
let me share the script and Japanese document. I hope this AN will be useful for you.
The script has been checked no syntax error and good behavior of the script with IMC101T-T038 v1.03.03.
c.f. AN2021-14 in English
Constant air-flow control using iMOTION™ script language
Best Regards,
Kazunari Hayashi
All,
if you check first behavior of "XMC4700 Relax Kit Lite", this article is helpful for you.
1. Open DAVE
2. Import "CCU4_SLICE_CONFIG_EXAMPLE_XMC47"
3. Build & start debug it
4. You can check PWM signal as "2022_05_10 XMC4700 Relax Kit Lite試用.pdf"
Best Regards,
Kazunari Hayashi
I have just posted this code for your reference or as a test tool.
[Overview]
This code is based on a "UART2_TTY_EXAMPLE_TLE984x" sample code.
I modified the code as a base software for any function test which can control via UART2.
If you will test some function repeatedly, this code may help you.
This code has three test code as the below.
Key=1: VDDEXT_LED = On
Key=2: VDDEXT_LED = Off
Key=3: 1[sec] timer
Each test code can execute by key input via terminal software on your PC.
For example, If you type [1] key then VDDEXT_LED will be turn on.
You can change the each test code for your test purpose.
This code is including the following functions. These code may also help you.
1, A sample test subroutine which prints 1~9 every second via UART2.
2, put_HexByte(uint8 data) : Convert one hexadecimal data into one ASCII data and then send it via UAR2.
3, put_HexWord(uint16 data) : Convert two hexadecimal data into two ASCII data and then send it via UAR2.
4, Delay_100us(uint32_t data) : 100[us] delay function which is using a Delay_us() function
[Environment]
Confirmed evaluation boards :
1) TLE984x Evalboard ( J16 = JP27 = JP28 = Short)
2) TLE9844-2QX Application Kit
IDE :
1)uVision V5.36.0.0
Software :
1) UART2_TTY_EXAMPLE_TLE984x_FuncTEST.zip
[Instructions]
1) Program this software into your evaluation board via uVision
2) Execute any terminal software (ex. TeraTerm) and connect with evaluation board at 115200bps.
3) Push RESET-SW on the evaluation board.
4) Follow the menu.
[Execution image]
Hiro.
Show LessHello all
We have uploaded the sample code to wake up from DeepSleep with the read / write of I2C slave below, but this time, We will upload the sample code to process the read / write operation in SCB_I2C_SlaveCompleteCallback.
The callback function ensures that the read / write is done before the process of entering DeepSleep.
Show Less
Hi,
In a discussion Matrix Key Sample using interrupt and debouncing was hoped.
So I modified my old 4x4 Matrix Keypad Sample
https://community.infineon.com/t5/Code-Examples/4x4-Matrix-Keypad-Sample/m-p/96977#M370
trying to fulfill the requirement. (As usual, there should be infinite approaches to do that though).
schematic
Pins
main.c
#include "project.h"
#include "stdio.h"
#define NUM_ROW 4
#define NUM_COL 4
#define DEBOUNCE_COUNT 4
volatile uint8_t key[NUM_ROW][NUM_COL] = { 0u } ;
uint8_t letter[NUM_ROW][NUM_COL] = {
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '*', '0', '#', 'D' }
} ;
volatile int row_no = 0 ;
volatile int col_no = 0 ;
volatile int matrix_key_pushed = 0 ;
volatile int matrix_key_released = 0 ;
CY_ISR(key_pushed_isr)
{
uint8_t tmp ;
tmp = Control_Reg_Read() ^ 0x01 ;
Control_Reg_Write( tmp ) ;
key_pushed_int_ClearPending() ;
matrix_key_pushed = 1 ;
}
CY_ISR(key_released_isr)
{
uint8_t tmp ;
tmp = Control_Reg_Read() ^ 0x02 ;
Control_Reg_Write( tmp ) ;
key_released_int_ClearPending() ;
matrix_key_released = 1 ;
}
void scan_key_matrix(void)
{
int key_pushed = 0 ;
switch(row_no) {
case 0: ROW0_Write(1) ; ROW1_Write(0) ; ROW2_Write(0) ; ROW3_Write(0) ; break ;
case 1: ROW0_Write(0) ; ROW1_Write(1) ; ROW2_Write(0) ; ROW3_Write(0) ; break ;
case 2: ROW0_Write(0) ; ROW1_Write(0) ; ROW2_Write(1) ; ROW3_Write(0) ; break ;
case 3: ROW0_Write(0) ; ROW1_Write(0) ; ROW2_Write(0) ; ROW3_Write(1) ; break ;
default: ROW0_Write(0) ; ROW1_Write(0) ; ROW2_Write(0) ; ROW3_Write(0) ; break ;
}
switch(col_no) {
case 0: key_pushed = COL0_Read() ; break ;
case 1: key_pushed = COL1_Read() ; break ;
case 2: key_pushed = COL2_Read() ; break ;
case 3: key_pushed = COL3_Read() ; break ;
}
if (key_pushed) {
if (key[row_no][col_no] == (DEBOUNCE_COUNT - 1)) {
Control_Reg_Write(0x01) ; // matrix_key_pushed = 1 ;
}
if (++key[row_no][col_no] >= DEBOUNCE_COUNT) {
key[row_no][col_no] = DEBOUNCE_COUNT ;
}
} else {
if (key[row_no][col_no]) {
Control_Reg_Write(0x2) ; // matrix_key_released = 1 ;
}
key[row_no][col_no] = 0 ;
}
col_no++ ;
if (col_no >= NUM_COL) {
col_no = 0 ;
row_no = (row_no + 1) % NUM_ROW ;
}
ROW0_Write(0) ;
ROW1_Write(0) ;
ROW2_Write(0) ;
ROW3_Write(0) ;
}
CY_ISR(my_tick_isr)
{
scan_key_matrix() ;
}
#define STR_LEN 64
char str[STR_LEN+1] ;
void print(char *str)
{
UART_PutString(str) ;
}
void printc(char c)
{
UART_PutChar(c) ;
}
void cls(void)
{
print("\033c") ; /* reset */
CyDelay(20) ;
print("\033[2J") ; /* clear screen */
CyDelay(20) ;
}
void splash(void)
{
cls() ;
print("5LP 4x4 Matrix Key Test") ;
snprintf(str, STR_LEN, "(%s %s)\n", __DATE__, __TIME__) ;
print(str) ;
}
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
splash() ;
CySysTickStart() ;
CySysTickSetCallback(0, my_tick_isr) ;
Control_Reg_Write(0x00) ;
key_pushed_int_ClearPending() ;
key_released_int_ClearPending() ;
key_pushed_int_StartEx(key_pushed_isr) ;
key_released_int_StartEx(key_released_isr) ;
}
void dump_key_matrix(void)
{
int col, row ;
for (row = 0 ; row < NUM_ROW ; row++) {
for (col = 0 ; col < NUM_COL ; col++) {
if (key[row][col]) {
snprintf(str, STR_LEN, "%c ", letter[row][col]) ;
print(str) ;
} else {
print("- ") ;
}
}
print("\n\r") ;
}
}
int main(void)
{
init_hardware() ;
dump_key_matrix() ;
for(;;)
{
if (matrix_key_pushed) {
matrix_key_pushed = 0 ;
cls() ;
dump_key_matrix() ;
}
if (matrix_key_released) {
matrix_key_released = 0 ;
cls() ;
dump_key_matrix() ;
}
}
}
moto
Show LessHi,
I saw a discussion about using LCD with PSoC 4
https://community.infineon.com/t5/PSoC-4/LCD-interfacing/td-p/352401
And when I ran search in Code Examples, the one I uploaded before was for PSoC 6.
So I hacked a one for PSoC 4. (Assuming HD44780 Char LCD Module)
The discussion asked for CY8C4045AZI445, which I could not find the datasheet,
right now the (seems to be) closest one I have was CY8CKIT-149 (CY8C4147AZI-S475).
So I made a sample project for this board.
Hopefully it will work with CY8C4045AZI by changing the target device and pin assign.
The top level schematic
Pins
In the datasheet of Character LCD
When build and programmed to the device, the LCD shows "LCD_TEST"
And Tera Term connected to the com port shows a splash line and a prompt "> "
Typing a string and hit enter key sends the string to the LCD
Note: the string "hello world" often gets corrupted,
may be we need to add some delay between letter and letter.
moto
Show Less
Hello,
This is a sample code for wakeup from DeepSleep using I2C slave communication for CY8CKIT-145-40XX.
In case of polling contrtol, the following code will be written as the main function.
************************************************************************************************************
for(;;)
{
/* Write buffer(master -> slave) */
if (0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_CMPLT)) ....... Conditional statement (1)
{
Processing the data, Clearing the buffer and status
}
/* Read buffer(master <- slave) */
if (0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_CMPLT)) ....... Conditional statement (2)
{
Clearing the buffer and status
}
/* Low power modes */
/* Enter critical section to lock the slave state */
uint8 intState = CyEnterCriticalSection();
/* Check if slave is busy */
status = (SCB_I2CSlaveStatus() & (SCB_I2C_SSTAT_RD_BUSY | SCB_I2C_SSTAT_WR_BUSY));
if (0u == status) ....... Conditional statement (3)
{
/* Slave is not busy: enter Deep Sleep */
SCB_Sleep(); /* Configure the slave to be wakeup source */
CySysPmDeepSleep();
/* Exit critical section to continue slave operation */
CyExitCriticalSection(intState);
SCB_Wakeup(); /* Configure the slave to active mode operation */
}
else
{
/* Slave is busy. Do not enter Deep Sleep. */
/* Exit critical section to continue slave operation */
CyExitCriticalSection(intState);
}
}
************************************************************************************************************
Conditional statement(3) may be processed before processing either conditional statement(1) or (2).
The read data for wakeup may be corrupted.
Then, the "if" statement of Conditional statement (3) is as follows.
************************************************************************************************************
status = (I2CS_I2CSlaveStatus() & (I2CS_I2C_SSTAT_RD_BUSY | I2CS_I2C_SSTAT_WR_BUSY));
if (0u == status && i2cs_deepsleep_flag == CLEAR)
{
}
************************************************************************************************************
The i2cs_deepsleep_flag is set in the void I2CS_I2C_SlaveCompleteCallback (void) API.
************************************************************************************************************
void I2CS_I2C_SlaveCompleteCallback(void)
{
if (0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_CMPLT) ||
0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_CMPLT))
{
i2cs_deepsleep_flag = SET;
}
}
************************************************************************************************************
As a result, data can be reliably written and read in I2C slave communication for wakeup.
Comment out "#define FLAG_CONTROL" in main.c to disable i2cs_deepsleep_flag.
************************************************************************************************************
/* I2C slave flag control for low power mode in case of WR & RD completion polling */
//#define FLAG_CONTROL
************************************************************************************************************
Best regards,
Yocchi
Show Less
Hi All,
This is sample code that uses SmartIO to eliminate switch input chattering with CY8CKIT-145-40XX.
The SmartIO clock is LFCLK. Since SmartIO can only count up to 6.4ms, two SmartIOs are needed to eliminate chattering in 100ms.
We generate a 5ms carry with Count up Wrap on SmartIO Port3.
After that, we use SmartIO Port2's Count up Wrap to count up the 5ms carry and create a 100ms carry.
In SmartIO Port2, Count up Wrap is reset when the Switch input is low level.
By inputting the P2_5 output to the Pin_INT input, chattering of 100 ms or less can be eliminated and an interrupt can be generated.
The blue parts and wiring are not included in the CY8CKIT-145-40XX. So you must prepare them.
Thanks and regards,
Show Less