Posted on Leave a comment

STM32F429I-DISC1

Datasheet for stm32F429ZI https://www.st.com/en/microcontrollers-microprocessors/stm32f429zi.html

This board have a 2.4 Resistive touch TFT LCD. which uses the ILI9341  controller.

The touch screen which I got with this display is very bad. you have to press down on the screen before you power ON the device.

The microcontroller is based on the ARM CORTEX M4F which can be clocked up to 180MHz. This particular board has an 8Mbyte of SDRAM included which is basically useless with this screen. If you want to see the full potential you have to use the LTDC peripheral which when configured with DMA2D gives you a very powerful development board with multimedia capabilites.

Posted on Leave a comment

STM32F746IGT6 – An ARM CORTEX M7 Based Microcontroller

Datasheet

It’s an ARM Cortex M7 based microcontroller which has a maximum clock speed of 216Mhz.

Well, it has a few peripherals which when combined with its CPU, makes it a very powerful controller.

Those peripherals are LTDC, SDRAM Controller.

It also has the usual set of peripherals from the ST. But these in particular makes it a very powerful microcontroller.

Posted on Leave a comment

How to redirect printf() to USART in STM32f103RB using STM32Cube IDE

Printf() function can be redirected to USART and also towards SWO.

Here you will see how to redirect printf() to USART in STM32f103RB

You need to rewrite this code in your main.c file

/*
* Function Name: _write
* Function Description: Redirect the printf() statement towards the UART using the HAL_UART_Transmit
Author: Abhay

*/
int _write(int fd, char* ptr, int len) {
    HAL_UART_Transmit(&huart1, (uint8_t *) ptr, len, HAL_MAX_DELAY);
    return len;
}

If you have created your project using STM32CubeMX or STM32 Cube IDE, then you can rewrite it in between USER CODE BEGIN 0 as shown

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
int _write(int fd, char* ptr, int len) {
    HAL_UART_Transmit(&huart1, (uint8_t *) ptr, len, HAL_MAX_DELAY);
    return len;
}
/* 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();
  /* USER CODE BEGIN 2 */
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */

  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */
}

After adding the code, connect the uart to your laptop or computer using serial to USB adapter and open serial Terminal application like YAT.
Then you will be able to see printf message over there.

Posted on Leave a comment

How to make ATmega GPIO work as Input or Output

AVR Input Output Port programming means you have to program its GPIO pins.

GPIO – General Purpose Input and Output

The GPIO is a very important peripheral of the microcontroller. Using the GPIO we can use the same exact pin for Input or Output.

To make the PIN input or output we need to set a bit in the data direction register DDR

Now lets take the example of ATmega16. Atmega 16 has 4 ports.
-PORT A
-PORT B
-PORT C
-PORT D

Each PORT has 8 pin
Each pin can be addressed individually
PortA.1 = Pin 1 of Port A
PA.1 = Pin 1 of Port A

To make a PIN input/output
DDRx = 1 // make the pin output
DDRx = 0 // make the pin input

Here x is to be replaced by port number
DDRA = DDR for port A


To Set the value of the pin we use
PORTx = 1 // set all the pins of the port to HIGH
PORTx = 0// Set all the pins of the port to LOW

To Read the value of the pin we use
PINx
usage:
int read_in;
DDRx = 0;
PORTx = 1; // This will enable the internal Pull up
read_in = PINx; // read_in variable will store the value in PINx

If the internal pull-up is not enabled than then value of the pin will always be in a floating state and it will not tell the accurate result.
When the internal pull-up is not enabled then the external pull has to be enabled by the user.

Posted on Leave a comment

Analog Modulation based Transmitter using ATmega16a

Analog Modulation is the very basic form of modulation that can be produced using very basic components.

The ATmega16a is used to generate a square wave. The frequency can be generated by carefully adjusting the 8-bit PWM Timer.

Using the above method a Carrier Signal is generated.

You can hear the carrier pulses on AM Radio. The reception is full of noise and interference.

The range of such signals is not good. Since the EM wave has very low power.

The circuit is given below.

AM transmitter using ATmega16a

AM Transmitter circuit

/*
 * AM Transmitter.c
 *
 * Created: 11/10/2021 9:59:04 PM
 * Author : abhay
 */ 
#define F_CPU 16000000
#include <avr/io.h>
#include <util/delay.h>


void delay1(){
	_delay_ms(20);
}

int main ()
{
	
	TCCR0 = (1 << WGM01) | (1 << COM00) | (1 << CS00);
		DDRB|=(1<<PB3);  /*set OC0 pin as output*/
	
	while (1)
	{
		OCR0 = 4;	// 1600 KHz
		
		delay1();    //This delay will create pulse of carrier frequency

		OCR0 = 12;	//  615 kHz

		delay1();    //This delay will create pulse of carrier frequency



	}
}

PWM signal is being produced by an 8bit timer of the microcontroller.

The formula used for the value of OCR0

Where

f clk_I/O = 16000000

N = 1

OCRn = (1,2,3 … 255)

Frequency calculated using the formula

The Antenna Used for AM Transmission in this setup is of very small length. Its range and quality get improved if you touch the antenna with your bare hands.

Posted on Leave a comment

Memory Space in ATmega16A

To effectively program AVR based microcontroller you must have knowledge about its memory space. Since there is not just one memory space. There are three different address spaces. They are:

  1. Data memory (SRAM)
    Here all your the intermediate results are stored and all the run time calculation get carried in this memory space.
  2. Program memory
    It is the memory where your application code is stored. And also it stores the constants. It could be divided into two sections by setting appropriate fuse bits. The two section will be:
    1. Application Section
    2. Boot Section
  3. EEPROM
    This is the memory where you can save the run time data such as configuration options, intermediate result for future processing. But it is very limited in size. So proper managment had to be taken care. Since it limits the size of certain applications.

Out of the three memories present in the ATmega16a, only the SRAM is volatile.

Size and address of memory space

  1. Data Memory
    1024 Bytes (Starting Address: 0x0060 – Last Address: 0x045F)
    96 Address which contain two section General purpose Register and I/O Registers.
    General Purpose Register ( Starting Address: 0x0000 – Last address: 0x001F)
    I/O register (Starting Address: 0x0020 – Last address: 0x005F)
  2. Program Memory
    Flash Type memory organised into 8000 memory location each pointing to a 16 bit wide data.
    Starting Address: 0x0000
    Last Address: 0x1FFF

NOTE: Care must be taken while Read/Write operations of EEPROM. It is very sensitive to operating conditions. Variations outside the tolerance limits could result in corruption of data in the worst case total loss of stored data. It is highly recommended that a stable power source must be used if performing frequent EEPROM operations.

Posted on Leave a comment

Arm Based Microcontrollers

At the time of writing this article ARM-based microcontroller means the microcontroller which uses a 32-bit RISC processor design from ARM holdings.

Presently ARM Cortex-M series of processor cores are being integrated into microcontrollers.

The ARM-Cortex M family comprises the following processors.

  • Cortex-M0
  • Cortex-M0+
  • Cortex-M1
  • Cortex-M3
  • Cortex-M4
  • Cortex-M7
  • Cortex-M23
  • Cortex-M33
  • Cortex-M35P
  • Cortex-M55

The Cortex-M4 / M7 / M33 / M35P / M55 cores also have a hardware-based floating-point unit. The addition of a Floating point unit adds the capabilities for digital signal processing.

To see a list of ARM-based microcontrollers.

Keil.com has a great list that has almost all the major microcontrollers out in the market and is supported by the Keil IDE.

https://www.keil.com/dd/chips//arm.htm
Posted on Leave a comment

Compile AVR Code in Raspberry Pi

I have recorded a video showing the steps to compile AVR code.

In this video, you will see how to compile AVR led blinking code for the atmega32 microcontroller is being compiled using AVR-GCC in raspberry pi 3 b+.

Step 1. : Create a file and put your avr c code in that file. Save that file with a “.c” extension

Step 2. : Run the following commands one by one

avr-gcc -g -0s -mmcu=atmega32 -c led.c
avr-gcc -g -mmcu=atmega32 -o led.elf led.o
avr-objcopy -j .text -j .data -o ihex led.elf led.hex

Step 3. : The step 2 will create a hex file. which can be uploaded to the microcontroller with the help of a programmer.

Posted on Leave a comment

How to install AVR-GCC Compiler in raspberry pi

In this video, you will see that how avr compiler can be installed in raspberry pi model 3 b+.

For steps on how to install avrdude in raspberry pi you can go here.

http://www.exasub.com/component/integrated-circuit/microcontroller/avr/using-usbasp-v2-0-avr-programmer-with-raspberry-pi-3/

AVR compiler and avrdude together on raspberry pi make it a development environment for embedded systems involving Avr microcontroller.

Posted on Leave a comment

Using USBASP V2.0 AVR Programmer with Raspberry Pi 3

Raspberry pi or Rpi can be used for programming certain AVR microcontrollers. I have made a video showing you the steps.

Step 1: you have to install AVRDUDE

sudo apt-get install avrdude -y

Step 2: You can check if the avrdude is installed properly or not using

avrdude

step 3: connect your USBASP v2.0 to your microcontroller

avrdude -c usbasp -p m32

Microcontroller Programmed:

Atmega32, atmega32a, Atmega16, Atmega16a,