Sunday, November 3, 2019

upper,lower,title,swapcase,capitalize methods in python


example 1:

s="Anil Durgam Learning Python"
print(s.upper())
print(s.lower())
print(s.swapcase())
print(s.title())
print(s.capitalize())

output:
ANIL DURGAM LEARNING PYTHON
anil durgam learning python
aNIL dURGAM lEARNING pYTHON
Anil Durgam Learning Python
Anil durgam learning python

join method in python

join method is used for to join the strings . especially used for the list and tuples

example 1:
list joining using join method
s=["anil", "durgam", "embedded"]
l="-".join(s)
print(l)

output:
anil-durgam-embedded

example 2:
tuple joining with join method
s=("anil", "durgam", "embedded")
l="-".join(s)
print(l)

output:
anil-durgam-embedded

example 3:
s=("anil", "durgam", "embedded")
l=":".join(s)
print(l)

output:
anil:durgam:embedded

example 4:
s=("anil", "durgam", "embedded")
l=" ".join(s)
print(l)

output:
anil durgam embedded

example 5:
s=("anil", "durgam", "embedded")
l="".join(s)
print(l)

output:
anildurgamembedded

rsplit method in python

rsplit method is used for  to print the given string in right to left direction

example 1:
s="10 20 30 40 50 60 70 80"
l=s.rsplit(" ",3)
print(l)
for x in l:
    print(x)

output :
10 20 30 40 50
60
70
80

example 2:

s="10 20 30 40 50 60 70 80"
l=s.rsplit(" ",4)
print(l)
for x in l:
    print(x)

output:

10 20 30 40
50
60
70
80

default value for the rsplit is  -1
s="10 20 30 40 50 60 70 80"
l=s.rsplit(" ",-1)
print(l)
for x in l:
    print(x)

output:
10
20
30
40
50
60
70
80

Saturday, November 2, 2019

split method in python


example 1:
split method is used for to split the given string in the left to right direction

s="anil durgam embedded"
l=s.split()
print(l)

output:
['anil', 'durgam', 'embedded']

example2:

s="anil durgam embedded"
l=s.split()
print(l)
for x in l:
    print(x)

output:
['anil', 'durgam', 'embedded']
anil
durgam
embedded


example 4:

s="03-11-2019"
l=s.split("-")
print(l)
for x in l:
    print(x)

output:
['03', '11', '2019']
03
11
2019


example 5:

s="anil durgam embedded developer india"
l=s.split(" ",3)
print(l)
for x in l:
    print(x)

output:
anil
durgam
embedded
developer india

example 6:
s="10 20 30 40 50 60 70 80"
l=s.split(" ",3)
print(l)
for x in l:
    print(x)

output:
10
20
30
40 50 60 70 80


replace method in python

s="ababa"
print(s)
s1=s.replace('a','b')
print(s1)

output:
ababa
bbbbb

example 2:


s="ababa"
print(s)
print("address of ::",id(s))
s1=s.replace('a','b')
print(s1)
print("address of ::",id(s1))

output:

ababa
address of :: 1358579616712
bbbbb
address of :: 1358567155280


example 3:

string data type is immutable but create the new object



s="ababa"
print(s)
print("address of ::",id(s))
s=s.replace('a','b')
print(s)
print("address of ::",id(s))

output:
ababa
address of :: 1358579616712
bbbbb
address of :: 1358579722816

Tuesday, October 29, 2019

"sizeof" function in c language

#include <stdio.h>
#include <stdlib.h>

int main()
{
   int a =0;
   char c="b";
   float d=1.10;
   long e=12345678;
   double f=1234567812345;
   long double g=123456789;
   printf("int==%d\nchar==%d\nfloat====%d",sizeof(a),sizeof(c),sizeof(d));
   printf("\nlong==%d",sizeof(e));
   printf("\ndouble==%d",sizeof(f));
   printf("\nlong double==%d",sizeof(g));
    return 0;
}

output:

int==4
char==1
float====4
long==4
double==8

long double==12

note :i am using code block ide ...so my values are like this ....if your using any other compiler then values will be changed as per the compiler

Monday, October 28, 2019

MM32 INSTALLATION ON KEIL





IC PACKAGES

  • BQFPH - Bumpered Quad Flat Pack with Heat spreader:   This form of quad flat package utilises the pin protectors at the corners, it also has heat spreaders to enable larger levels of power to be dissipated.
  • CQFP - Ceramic Quad Flat Pack:   This is a high quality version of the quad flat pack using ceramic for the package.
  • FQFP - Fine pitched Quad Flat Pack:   A quad flat pack with, as the name indicates, a fine pitch for the pins.
  • HQFP - Heat sinked Quad Flat Pack:   With many integrated circuits, especially those with high pins counts which have a high level of circuitry may dissipate high levels of heat. This heat may need to be removed. To achieve this a number of the pins, often in the centre of opposing sides are replaced with a thicker pin which is soldered to a large pad on the PCB with a large area of copper connected to it. This will remove a significant amount of heat.
  • LQFP - Low profile Quad Flat Pack:   The Low Profile Quad Flat Pack is based upon the metric QFP, MQFP, but it is are thinner with a body thickness or height of 1.4mm. This helps solve problems where component height may be a problem. It has a standard lead-frame footprint - 2.0mm lead footprint. Lead counts for the LQFP range from 32 to 256. Body sizes range from 5 x 5mm to 28 x 28mm. Lead pitches available for LQFP package are 0.3, 0.4, 0.5, & 0.65mm.
  • MQFP - Metric Quad Flat Pack:   A quad flat package where the measurements and in particular the pin spacing is defined in metric dimensions. Standard QFPs normally use Imperial measurements and have pin spacing etc defined in terms of convenient Imperial dimensions.
  • PQFP - Plastic Quad Flat Pack:   A quad flat pack where the package material is plastic. Some QFPs can use ceramic.
  • TQFP - Thin Quad Flat Pack:   The Thin Quad Flat Pack, TQFP is a form of low profile quad flat pack. Having a body thickness of 1.0mm and have a standard lead-frame footprint with 2.0mm lead footprint. The TQFP package material used is plastic.

Wednesday, October 23, 2019

WHILE loop in python

EXAMPLE 1:
while 1:
    print("Hello")

output:
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
Hello
......

EXAMPLE 2:

x=0
while 1:
    print(x)

    x+=1

output:
1
2
3
4
5
.....

Tuesday, October 22, 2019

FOR loop in python

in loops concept For loop plays major role

range is inbuilt function which is having 3 integers values
range(start,stop,step)
start---from where to start the iteration
stop---upto which value(max value) to execute
step---how much increment is looking for each iteration


example 1:

for x in range(1,10):
    print(x)

out put:
1
2
3
4
5
6
7
8
9



example 2:

for x in range(1,10):

    print("*")

output:
*
*
*
*
*
*
*
*
*

nested for loop

for x in range(1,5):
    for y in range (1,5):

          print("*")

output:
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

example 4:
for x in range(2, 30, 3):
  print(x)

output:
2
5
8
11
14
17
20
23
26
29

example 5:
adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]

for x in adj:
  for y in fruits:

    print(x, y)

output:
red apple
red banana
red cherry
big apple
big banana
big cherry
tasty apple
tasty banana
tasty cherry

example 6:
sentence = ["the", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog"]

for i in sentence:
    print(i)
    i=+1

output:
the
quick
brown
fox
jumped
over
the
lazy
dog

Friday, September 27, 2019

stm32f103c8t6 with uart communication


main lines to add:
uint8_t bufftx[10]="Hello\n\r";
while (1)
  {
    /* USER CODE END WHILE */
HAL_UART_Transmit(&huart2, bufftx, 10,100);
HAL_Delay(1000);
    /* USER CODE BEGIN 3 */

  }



/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart2;

/* USER CODE BEGIN PV */
uint8_t bufftx[10]="Hello\n\r";

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USART2_UART_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
HAL_UART_Transmit(&huart2, bufftx, 10,100);
HAL_Delay(1000);
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Initializes the CPU, AHB and APB busses clocks
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the CPU, AHB and APB busses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief USART1 Initialization Function
  * @param None
  * @retval None
  */
static void MX_USART1_UART_Init(void)
{

  /* USER CODE BEGIN USART1_Init 0 */

  /* USER CODE END USART1_Init 0 */

  /* USER CODE BEGIN USART1_Init 1 */

  /* USER CODE END USART1_Init 1 */
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 115200;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART1_Init 2 */

  /* USER CODE END USART1_Init 2 */

}

/**
  * @brief USART2 Initialization Function
  * @param None
  * @retval None
  */
static void MX_USART2_UART_Init(void)
{

  /* USER CODE BEGIN USART2_Init 0 */

  /* USER CODE END USART2_Init 0 */

  /* USER CODE BEGIN USART2_Init 1 */

  /* USER CODE END USART2_Init 1 */
  huart2.Instance = USART2;
  huart2.Init.BaudRate = 9600;
  huart2.Init.WordLength = UART_WORDLENGTH_8B;
  huart2.Init.StopBits = UART_STOPBITS_1;
  huart2.Init.Parity = UART_PARITY_NONE;
  huart2.Init.Mode = UART_MODE_TX_RX;
  huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  if (HAL_UART_Init(&huart2) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART2_Init 2 */

  /* USER CODE END USART2_Init 2 */

}

/**
  * @brief GPIO Initialization Function
  * @param None
  * @retval None
  */
static void MX_GPIO_Init(void)
{

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */

  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/


output :

python class topic video