我正在做一个大学项目,其中包括使用6位7段显示器。我写了一个代码,应该在显示器上写双数,但我不能将双数发送到函数,也不能将双号转换为int然后发送。
我在Eclipse和Proteus工作。
这是代码:
void ispisbroja(int broj){
int c4 = (broj%1000000)/100000;
int c3 = (broj%100000)/10000;
int c2=(broj%10000)/1000;
int c1=(broj%1000)/100;
int c0=(broj%100)/10;
int cm1=(broj%10);
while(1){
GPIOC->BSRR |= (GPIO_BSRR_BS0); // setujemo pin PC0
switch(c4){
case 9:
devetka();
break;
case 8:
osmica();
break;
case 7:
sedmica();
break;
case 6:
sestica();
break;
case 5:
petica();
break;
case 4:
cetvorka();
break;
case 3:
trojka();
break;
case 2:
dvojka();
break;
case 1:
jedinica();
break;
default:
nula();
}
delay(100);
GPIOC->BSRR &= ~(GPIO_BSRR_BS0); // resetujemo pin PC0
GPIOC->BSRR |= (GPIO_BSRR_BR0); // resetujemo pin PC0
GPIOC->BSRR |= (GPIO_BSRR_BS1); // setujemo pin PC1
switch(c3){
case 9:
devetka();
break;
case 8:
osmica();
break;
case 7:
sedmica();
break;
case 6:
sestica();
break;
case 5:
petica();
break;
case 4:
cetvorka();
break;
case 3:
trojka();
break;
case 2:
dvojka();
break;
case 1:
jedinica();
break;
default:
nula();
}
delay(100);
GPIOC->BSRR &= ~(GPIO_BSRR_BS1); // resetujemo pin PC1
GPIOC->BSRR |= (GPIO_BSRR_BR1); // resetujemo pin PC1
GPIOC->BSRR |= (GPIO_BSRR_BS2); // setujemo pin PC2
switch (c2){
case 9:
devetka();
break;
case 8:
osmica();
break;
case 7:
sedmica();
break;
case 6:
sestica();
break;
case 5:
petica();
break;
case 4:
cetvorka();
break;
case 3:
trojka();
break;
case 2:
dvojka();
break;
case 1:
jedinica();
break;
default:
nula();
}
delay(100);
GPIOC->BSRR &= ~(GPIO_BSRR_BS2); // resetujemo pin PC2
GPIOC->BSRR |= (GPIO_BSRR_BR2); // resetujemo pin PC2
GPIOC->BSRR |= (GPIO_BSRR_BS3); // setujemo pin PC3
switch(c1){
case 9:
devetka(1);
break;
case 8:
osmica(1);
break;
case 7:
sedmica(1);
break;
case 6:
sestica(1);
break;
case 5:
petica(1);
break;
case 4:
cetvorka(1);
break;
case 3:
trojka(1);
break;
case 2:
dvojka(1);
break;
case 1:
jedinica(1);
break;
default:
nula(1);
}
delay(100);
GPIOC->BSRR &= ~(GPIO_BSRR_BS3); // resetujemo pin PC3
GPIOC->BSRR |= (GPIO_BSRR_BR3); // resetujemo pin PC3
GPIOC->BSRR |= (GPIO_BSRR_BS4); // setujemo pin PC4
switch(c0){
case 9:
devetka();
break;
case 8:
osmica();
break;
case 7:
sedmica();
break;
case 6:
sestica();
break;
case 5:
petica();
break;
case 4:
cetvorka();
break;
case 3:
trojka();
break;
case 2:
dvojka();
break;
case 1:
jedinica();
break;
default:
nula();
}
delay(100);
GPIOC->BSRR &= ~(GPIO_BSRR_BS4); // resetujemo pin PC4
GPIOC->BSRR |= (GPIO_BSRR_BR4); // resetujemo pin PC4
GPIOC->BSRR |= (GPIO_BSRR_BS5); // setujemo pin PC5
switch(cm1){
case 9:
devetka();
break;
case 8:
osmica();
break;
case 7:
sedmica();
break;
case 6:
sestica();
break;
case 5:
petica();
break;
case 4:
cetvorka();
break;
case 3:
trojka();
break;
case 2:
dvojka();
break;
case 1:
jedinica();
break;
default:
nula();
}
delay(100);
GPIOC->BSRR &= ~(GPIO_BSRR_BS5); // resetujemo pin PC5
GPIOC->BSRR |= (GPIO_BSRR_BR5); // resetujemo pin PC5
}
}
int main(void){
GPIO_Init();
double broj = 1234.66;
int broj2=broj;
broj2 = broj2 * 100;
ispisbroja(broj2);
}
我得到的错误:
D:toolchainGNU MCU EclipseARM Embedded GCC8.3.1-1.1bin/arm-none-eabi-ld.exe -T linker_script.ld -o build/domzad2_program.elf build/startup_code.o build/main.o build/util.o build/timer_pwm.o build/adc.o build/usart.o
D:toolchainGNU MCU EclipseARM Embedded GCC8.3.1-1.1bin/arm-none-eabi-ld.exe: build/main.o: in function `main':
main.c:(.text+0xdd4): undefined reference to `__aeabi_d2iz'
make: *** [makefile:92: build/domzad2_program.elf] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
谢谢!
您还需要链接库。很难在一篇简单的文章中解释如何配置工具链。
我建议安装stmCubeIde,它将为您进行配置。