This is a Lesson-0 for developing on Infineon microcontrollers.In this prelude, I do a simple "Embedded Hello World" application from scratch.
All I know about Infineon MCUs, you could learn from below links:
https://github.com/Infineon/Code-Examples-for-ModusToolbox-Software
https://github.com/Infineon/modustoolbox-software
https://github.com/Infineon/training-modustoolbox
https://github.com/Infineon/AURIX_code_examples
In Lesson-0, I will do the following:
- (A) Creating a new ModusToolboxapplication
- (B) Add Library
- (C) Sending "Hello Embedded World" to PC via UART
(A1) Start Eclipse IDE for ModusToolbox
(A2) Create...\InfineonMCU\lsnPSoC6 somewhere on your computer as Workspace
(A3) Quick Panel -> Start -> New Application
(A4) Kit Name -> PSoC6 BSPs -> CY8CKIT-062S2-43012
(A5) Template Application -> Getting Started -> Empty App
(A6) New Application Name: helloEmbeddedWorld
(A7) Project Explorer -> helloEmbeddedWorld -> main.c : open the main.c and clear file and wire the following
int cnt;
int main()
{
for(;;)
{
cnt++;
}
}
(A8) Press (Ctrl + B) to build the project. You have to ecevie a message akin to: 22:07:12 Build Finished. 0 errors, 0 warnings. (took 84ms)
(A9) Quick Panel -> Launches -> helloEmbeddedWorld Debug (KitProg3_MiniPorg4)Add cnt as Expression in "Expressions" tap right to Quick PanelPress F6 to see the int value will be incremented.
(B1) Quick Panel -> Library Manger -> Add Library -> Peripheral -> retarget-io Click OK and then Click Update
(B2) Include the retarget-io library in the main.c
#include "cy_regarget_io.h"
(C1) Change main.c to the following:
#include "cyhal.h"
#include "cybsp.h"
#include "cy_retarget_io.h"
int main()
{
cy_rslt_t result;
result = cybsp_init();
if (result != CY_RSLT_SUCCESS) CY_ASSERT(0);
result = cy_retarget_io_init(P5_1, P5_0, 9600);
if (result != CY_RSLT_SUCCESS) CY_ASSERT(0);
printf("***********************************************************\r\n");
printf("Hello Embedded World \r\n");
printf("***********************************************************\r\n");
for(;;) {}
}
(C2) Install and open RealTerm application or your favorite terminal emulator program such as Tera Term or Termite or PuTTY and so on.
(C3) run the application by:Quick Panel -> Launches -> helloEmbeddedWorld Program (KitProg3_MiniProg4)and you will see that "Hello Embedded World" show at RealTerm screen:
- To see int variable cnt in Live Expressions, you have to declare it as global variable. If you declare it inside the main() function, it won't work.
- typedef uint32_t cy_rslt_t;
- cy_retartet_io_init(cyhal_gpio_t tx, cyhal_gpio_t rx, uint32_t buadrate) result = cy_retarget_io_init(P5_1, P5_0, 9600);
- In cycfg_pins.h, we can find which pins are used as uart or gpio or i2c and...Project Explorer -> helloEmbeddedWorld -> bsps -> TARGET_APP_CY8CKIT-062S2-43012 -> config -> cycfg_pins.h
#define CYBSP_DEBUG_UART_RX (P5_0)
#define CYBSP_DEBUG_UART_TX (P5_1)
So alternatively, we can write:
result = cy_retarget_io_init(CYBSP_DEBUG_UART_TX , CYBSP_DEBUG_UART_RX , 9600);
- It would be useful to see cy_retarget_io.h
#define CY_RETARGET_IO_BAUDRATE (115200)
- In UAR Lesson, we will use functions defined in cyhal_uart.h
cy_rslt_t cyhal_uart_putc(cyhal_uart_t *obj, uint32_t value);
cy_rslt_t cyhal_uart_getc(cyhal_uart_t *obj, uint8_t *value, uint32_t timeout);
Comments
Please log in or sign up to comment.