Grüezi mitenand,
Also ich möchte mit meinem 8051f020 eine AD Wandlung durchführen. Habe
das ganze versucht zu simulieren läuft aber leider gar nix.
Es stellt sich mir die Frage was falsch ist am Code, wäre echt froh für
eine kleine hilfestellung...
QuellCode :
#include "C8051F020.h"
sbit Sensor11 = P2^0; // Definitionen Port Outputs
sbit Sensor12 = P2^1;
sbit Sensor21 = P2^2;
sbit Sensor22 = P2^3;
sbit Sensor31 = P2^4;
sbit Sensor32 = P2^5;
void Port_IO_Init()
{
P1MDIN = 0x00;
P2MDOUT = 0xFF;
XBR0 = 0x10;
XBR2 = 0x40; //Crossbar enable
WDTCN = 0xDE; //Watchdog disable
WDTCN = 0xAD;
}
void ADC_Init()
{
ADC1CN = 0x88;
REF0CN = 0x02;
}
void main(void)
{
Port_IO_Init();
while(1)
{
int ist_feuchte;
ADC_Init();
ist_feuchte =Feuchte();
if (ist_feuchte > 0 )
{
Sensor12 = 1;
Sensor21 = 1;
}else
{
P2 = 0;
}
}
}
int ist_feuchte;Feuchte()
{
int ist_feuchte;
AMX1SL0x01; // select ADC-Channel P1.1
AD0BUSY=1; // starte ADC
while(AD0BUSY == 1){} // Warten während Wandlung
ADC1 = ist_feuchte;
return ist_feuchte;
}
Grüsse,
Kay
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.