I wrote the following code for LCD interfacing of the 8051 microcontroller using strings and pointers. I declared two strings namely str1 and str2 and pointers ptr1 and ptr2 respectively. When I initiliasied both the pointers to the starting of the strings, I got the error C231 saying that ‘ptr1’ : redefinition and same for ptr2. Following is the code:
#include<reg51.h>
char str1[]="abcd";
char str2[]="efgh";
int i;
char *ptr1;
ptr1=&str1[0];
char *ptr2;
ptr2=&str2[0];
sbit rs=P1^0;
sbit wr=P1^1;
sbit en=P1^2;
void delay()
{
int i,j;
for(i=0;i<100;i++)
for(j=0;j<1275;j++);
}
void lcd_inl()
{
comwrt(0x38);
comwrt(0x0f);
comwrt(0x01);
comwrt(0x81);
}
void datwrt(char)
{
P2=ch;
rs=1;
wr=0;
en=1;
delay();
en=0;
}
void comwrt(int)
{
P2=i;
rs=0;
wr=0;
en=1;
delay();
en=0;
}
void main()
{
P1=0x00;
P2=0x00;
lcd_inl();
delay();
while(!*ptr1)
{
datwrt(*ptr1);
ptr1++;
}
delay();
while(!*ptr2)
{
comwrt(0xc1);
delay();
datwrt(*ptr2);
ptr2++;
}
while(1);
}
asked Dec 27, 2016 at 17:06
18
This line
ptr1=&str1[0];
must be within a function, as must all executable code, apart from initialisation statements incorporated as part of the definition.
So you would need
char *ptr1 = str1;
Edit (from OP’s comment) like this:
#include<reg51.h>
char str1[]="abcd";
char str2[]="efgh";
int i;
char *ptr1 = str1;
char *ptr2 = str2;
sbit rs=P1^0;
sbit wr=P1^1;
sbit en=P1^2;
I have looked in reg51.h and there is no str1
or str2
or ptr1
or ptr2
. So if you are still getting an error, there is something you haven’t told us.
answered Dec 27, 2016 at 17:47
Weather VaneWeather Vane
33.2k7 gold badges36 silver badges56 bronze badges
6
Сообщение от Витальич
(правда в IAR это пародия на симулятор)
Тем не менее почему-то все пишут на IAR …. на Keil только под 8051 и язык не особо распространен.
Добавлено через 21 секунду
Хотя я могу и заблуждаться
Добавлено через 6 минут
Далее хочу сделать задержку времени
C++ | ||
|
Получаю ошибку :
Warning[Pe223]: function "__delay_cycles" declared implicitly C:UsersUserDocumentsmain.c 49
Warning[Pe111]: statement is unreachable C:UsersUserDocumentsmain.c 51
Linking
Error[e46]: Undefined external "__delay_cycles" referred in main ( C:UsersUserDocumentsDebugObjmain.r51 )
Я так понимаю он ругается на то что нет такой функции, но в мануалах пишут что это стандартный вызов задержки по времени … ?
Добавлено через 14 минут
и еще не понятны следующие моменты:
C | ||
|
Как мне узнать как обозначается шина данных в моем чипе ? как вообще находить шину данных на любом чипе ?
Порт к которому подкл. упр. шина :
C | ||
|
я для своего камня заменяю на
?
Дальше вот эта часть мне не понятна как объявить для моего камня :
C | ||
|
Далее вот эта часть :
C | ||
|
Я так понимаю устанавливает просто биты ? например
исходя из этого :
C | ||
|
Спасибо за ответы, и вашу помощь. С праздником вас.
Open
Issue created Jan 18, 2022 by lcwang0@lcwang0Maintainer
SPI sample code compilation error out of the box
Created by: LovelyA72
I am compiling a fresh SPI_Flash sample code from this repository.
The code is unmodified.
I am getting the following errors
Rebuild started: Project: SPI_Flash
Rebuild target 'SPI_Flash'
compiling SPI_Flash.c...
compiling Common.c...
....IncludeFunction_Define.h(9): error C231: 'BIT': redefinition
....IncludeFunction_Define.h(10): error C231: 'UINT8': redefinition
....IncludeFunction_Define.h(11): error C141: syntax error near 'UINT16', expected 'hdata'
....IncludeFunction_Define.h(12): error C141: syntax error near 'UINT32', expected 'hdata'
....IncludeFunction_Define.h(14): error C231: 'uint8_t': redefinition
....IncludeFunction_Define.h(15): error C141: syntax error near 'uint16_t', expected 'hdata'
....IncludeFunction_Define.h(16): error C141: syntax error near 'uint32_t', expected 'hdata'
....IncludeFunction_Define.h(18): error C231: 'int8_t': redefinition
....IncludeFunction_Define.h(19): error C141: syntax error near 'int16_t', expected 'hdata'
....IncludeFunction_Define.h(20): error C141: syntax error near 'int32_t', expected 'hdata'
compiling Delay.c...
assembling STARTUP.A51...
Target not created.
1Answers
Asked by: Betty Bennett
310 views
IT
June 7, 2021
#include
sbit wei=P1^5;
sbit duan=P1^6;
int i,j,k,tables;
tables[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d.0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71}//1,2,3,4,5……E,F
void main()
{
while(1)
{
for(k=0;k>12;k++)
{
duan=1;
P0=tables[k];
duan=0;
P0=0XEE;
for(i=200;i>0;i—)
for(j=200;j>0;j—);
wei=1;
P0=0x0e;
wei=0;
for(i=200;i>0;i—)
for(j=200;j>0;j—);
}
}
}
事牍?c(6): error C231: ‘tables’: redefinition
事牍?c(7): error C141: syntax error near ‘.0’, expected ‘}’
事牍?c(11): error C141: syntax error near ‘{‘, expected ‘;’
事牍?c(16): error C231: ‘duan’: redefinition
事牍?c(16): error C231: ‘duan’: redefinition
事牍?c(17): error C231: ‘P0’: redefinition
事牍?c(17): error C231: ‘P0’: redefinition
事牍?c(18): error C279: ‘duan’: multiple initialization
事牍?c(18): error C231: ‘duan’: redefinition
事牍?c(18): error C231: ‘duan’: redefinition
事牍?c(19): error C279: ‘P0’: multiple initialization
事牍?c(19): error C231: ‘P0’: redefinition
事牍?c(19): error C231: ‘P0’: redefinition
事牍?c(20): error C141: syntax error near ‘for’, expected ‘hdata’
事牍?c(20): error C141: syntax error near ‘=’, expected ‘)’
事牍?c(20): error C129: missing ‘;’ before ‘>’
求大佬解答
@priteshrnandgaonkar this is what needs to be changed to repro:
platform :ios, '10.3' # was 9.0
require_relative '../../../node_modules/@react-native-community/cli-platform-ios/native_modules'
def add_flipper_pods!
version = '~> 0.33.1'
pod 'FlipperKit', version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => 'Debug'
pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitReactPlugin', version, :configuration => 'Debug'
end
# Post Install processing for Flipper
def flipper_post_install(installer)
installer.pods_project.targets.each do |target|
if target.name == 'YogaKit'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end
target 'v1' do
# Pods for v1
pod 'FBLazyVector', :path => "../../../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../../../node_modules/react-native/Libraries/FBReactNativeSpec"
...
use_native_modules!
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
add_flipper_pods!
post_install do |installer|
flipper_post_install(installer)
# this post build is necessary for other dependencies to work, since they use api's not available in 9.0
installer.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.3'
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
end
end
end
target 'v1-tvOS' do
# Pods for v1-tvOS
target 'v1-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Also had to change the main project to 10.3