cancel
Showing results for 
Search instead for 
Did you mean: 

Im trying to control the Arduino Multifunction Shield by using stm32l053r8t6. What is the coding for the 4-digits 7segment on the multi function shield?

BTan.5
Associate II

Im only can display the 7segment by using "sortSegment (numbers);" and it only display at 4th 7segment. How can i select which 7segment i want to display, and how can i display Characters?

5 REPLIES 5
gbm
Lead III

Check the schematics of your board - you will see the connections.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

You have to shift in 4 digits

D8=data, D7=clk, D4=latch

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
BTan.5
Associate II


_legacyfs_online_stmicro_images_0693W00000bk0XeQAI.png this is the schematics of my Arduino Multifunction shield, and i just connect it to my stm32l053r8t6. Can someone teach me how to display my 7segment? Im already set the pin (PB5, PA8, PA9) to the gpio_output. Now i can only display numeric numbers, how to display characters?

BTan.5
Associate II

Please teach me how to display characters and how to select which 7segment to display. Im already include the .c and .h files and i cannot understand it because im new to stm32��

// this is .h file
#include "stm32l0xx_hal.h"
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
 
//=================================================================== I/O Pins AML
#define LOW 		GPIO_PIN_RESET
#define HIGH 		GPIO_PIN_SET
 
#define dataS(x)	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, x? HIGH:LOW)
#define shCLK(x) 	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, x? HIGH:LOW)
#define stCLK(x) 	HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, x? HIGH:LOW)
 
#define BUZ(x) 		HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3 ,x? LOW:HIGH)
 
#define LED1(x) 	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5,x? LOW:HIGH)
#define LED2(x) 	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6,x? LOW:HIGH)
#define LED3(x) 	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7,x? LOW:HIGH)
#define LED4(x) 	HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6,x? LOW:HIGH)
 
#define S1 			HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_1)
#define S2 			HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_4)
#define S3 			HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_0)
 
//=================================================================== Function Prototype
uint8_t getPB(void);
void LEDs(uint8_t decimal);
void displaySegment(void);
void multiplexSegment(uint16_t num4digit);
 
 
// this is the .c file
#include "praQdriver.h"
 
// Array data & variables used for 7-segment Common Anode - numeric value only
const uint8_t num[10] 	= {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
const uint8_t seg[4]	= {0xF1,0xF2,0xF4,0xF8};
uint16_t ptr2disp;
uint16_t buff[4];
 
 
uint8_t getPB(void)
{	uint8_t PBvalue=0;
 
	if(S1!=HIGH)	PBvalue |= 1<<0;
	if(S2!=HIGH)	PBvalue |= 1<<1;
	if(S3!=HIGH)	PBvalue |= 1<<2;
	return PBvalue;
}
void LEDs(uint8_t decimal)
{	LED1(decimal & 1<<0);
	LED2(decimal & 1<<1);
	LED3(decimal & 1<<2);
	LED4(decimal & 1<<3);
}
void displaySegment(void)
{	static uint8_t seg=0;
 
	stCLK(LOW);
	for(int8_t i=15;i>-1;i--)
	{	shCLK(LOW);
		if(buff[seg] & (1<<i))	dataS(HIGH);
		else					dataS(LOW);
		shCLK(HIGH);
	}
	stCLK(HIGH);
 
	if(++seg>3) seg=0;
}
void multiplexSegment(uint16_t num4digit)
{	for(uint8_t i=0;i<4;i++)
	{	switch(i)
		{	case 0:
				ptr2disp = num4digit / 1000;
				break;
			case 1:
				ptr2disp = (num4digit % 1000) / 100;
				break;
			case 2:
				ptr2disp = (num4digit % 100) / 10;
				break;
			case 3:
				ptr2disp = num4digit % 10;
				break;
		}
		buff[i] = (num[ptr2disp]<<8) | seg[i];
	}
}

But are the conceptual issues here STM32 related?

You've got a 16-bit shift register, one half is uses to select the digit to be selected, and the other half the 7-segments to illuminate.

You keep an MCU side buffer, and cycle thru the digits continuously, frequently enough for the scan/persistence to work.

Shift registers are a basic concept. You drive a bit, clock it into the chain, and then there's a latch to move the shifting register into a holding register.

Make sure you've properly initialized the GPIO pins.

If you have a scope or logic analyzer perhaps use those to confirm or review your understanding.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..