initial commit

This commit is contained in:
Fabian Schieder 2026-02-25 12:51:53 +01:00
parent 969363d03f
commit 0d1da79006
2 changed files with 102 additions and 5 deletions

View File

@ -259,17 +259,17 @@
<Size>0x0</Size>
</XRAM>
<OCR_RVCT1>
<Type>0</Type>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT1>
<OCR_RVCT2>
<Type>0</Type>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT2>
<OCR_RVCT3>
<Type>0</Type>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT3>
@ -279,7 +279,7 @@
<Size>0x20000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>0</Type>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT5>
@ -322,7 +322,7 @@
<PlainCh>0</PlainCh>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<wLevel>2</wLevel>
<wLevel>3</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>

97
main.c
View File

@ -1,5 +1,102 @@
#include <armv30_std.h>
#include <stm32f10x.h>
void portConfig()
{
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; // Takt für Port A
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN; // Takt für Port B
GPIOA->CRL &= 0x00000000;
GPIOA->CRL |= 0x22222222; // PA0 - PA7 Output
GPIOB->CRL &= 0x00000000;
GPIOB->CRL |= 0x00000022; // PB0 - PB1 Output
}
void set7Seg(uint8_t zahl)
{
const uint8_t segmente[10] =
{
0b00111111, // 0
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
0b01100110, // 4
0b01101101, // 5
0b01111101, // 6
0b00000111, // 7
0b01111111, // 8
0b01101111 // 9
};
if (zahl < 10)
{
GPIOA->ODR &= 0xFFFFFF00;
GPIOA->ODR |= segmente[zahl];
}
}
void segEnable(uint8_t zahl)
{
if(zahl == 1)
{
GPIOB->ODR &= 0b00000000;
GPIOB->ODR |= 0b00000001;
}
else if(zahl == 2)
{
GPIOB->ODR &= 0b00000000;
GPIOB->ODR |= 0b00000010;
}
}
uint8_t varTo7Seg(uint8_t zahl)
{
uint8_t einer = 0;
uint8_t zehner = 0;
int i = 0;
if(zahl > 99)
{
set7Seg(0);
}
else
{
einer = zahl % 10;
zehner = zahl / 10;
}
for(i = 0; i < 51; i++)
{
segEnable(1);
set7Seg(zehner);
wait_ms(5);
segEnable(2);
set7Seg(einer);
wait_ms(5);
}
return zahl;
}
int main(void)
{
portConfig();
uint8_t zahl = 99;
uint16_t tick = 0;
int i = 0;
while(1)
{
for(i = 0; i < 100; i++)
{
varTo7Seg(i);
}
wait_ms(2000);
i = 0;
}
}