-
Thread
Rechteckgenerator Warteschleife
'Warteschleige Pause Loop Until Timer1 = Pause Portc.3 = 1 'Ausgang auf High Timer1 = 0 'Reset Timer1 Do
Impuls Loop Until Timer1 = Impuls Loop Until Pinc.5 = 0 Portc.3 = 0 Disable Timer1 Goto Auswahl[/c]
-
Thread
Problem mit Bascom
Quelltest: Ddra = &B00000000 Ddrc = &B11111111 Ddrd = &B11111111 Config Porta = Input Config Portc = Output Config Portd = Output Do If Pina.0 = 1 Then Portd.0 = 1 Portc.0 = 1 Else Portc.0 = 0 Portd.0 = 0 End If Loop Wenn ich das auf meinen ATMEGA8515 überspiele und dann
Output stellen willst, das geht dann mit ddrx.. So müsste es gehen: Config Porta = Input Config Portc = Output Config Portd = Output Set Porta.0 'internen Pullup einschalten Do If Pina.0 = 1 Then Portd.0 = 1 Portc.0 = 1 Else Portc.0 = 0 Portd.0 = 0 End If Loop
-
Thread
Problem vom WinAVR? AVRStudio? Anwender?
ausgeführt wurde, bleibt das Programm stehen. [c] #include <avr/io.h> void funktion(void) { PORTC=0x05; // Programm bleibt hier stehen!!! } int main(void) { DDRC=0xFF; PORTC=0x00; funktion(); // Was nun folgt, wird nicht mehr ausgeführt while(1){ PORTC=0xff;
Funktion noch nichtmals ausgeführt wird. [c] #include <avr/io.h> void funktion(int x) { PORTC=x; } int main(void) { DDRC=0xFF; PORTC=0x00; // Programm bleibt hier stehen funktion(0x05); while(1){ PORTC=0xff; } return 0; } [/c] Am PORT C sind LEDs angeschloßen
-
Thread
DS1820
Port auf Ausgabe setzten und Pin's entsprechend zuordnen Ddrd = &HFF Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portd.1 , _ Db7 = Portd.0 , E = Portc.3 , Rs = Portc.2 Config Lcd = 16 * 2 Cursor Off Cls ' Pin für 1wire Schnittstelle festlegen, Schnittstelle wird von BASCOM
-
Thread
HD44780 8bittig ansteuern mit PIC18F4550
, RB7 #define RS PORTC, RC6 #define E PORTC, RC7 main CALL lcd_init CALL delay_20ms MOVLW 'A' CALL lcdchar MOVLW 'B' CALL lcdchar MOVLW 'C' CALL lcdchar loop GOTO loop lcd_init
> #define RS PORTC, RC6 > #define E PORTC, RC7 RW des LCD hast du auf GND verdrahtet? > lcd_init > BCF RS > CALL wait_20ms > MOVLW b'00110000' ;Interface auf 8bit setzen > CALL lcdcomm 20
-
Thread
Schaltet sofort alles ein!
4000000 Config Portc = Output Do Loop End Gruß Christian
'########### 'Lauflicht '########### $regfile = "m8def.dat" $crystal = 4000000 Config Portc = Output Portc = 0 Do If Pin..... = 1 then gosub Laufen else gosub Aus Loop Laufen: . . . . . . . Return Aus: Portc = 0 Return End Gruß Flo
-
Thread
ADC Programm
ADC_free_running(uint8_t channel) { DDRC = 0x00; //PC0 als Eingang definieren PORTC = 0x00; //Pullup an PORTC aus ADCSRA = ( (1<<ADFR) | (1<<ADPS2) | (1<<ADPS1) |(1<<ADIE) ); ADMUX = (1<<REFS0) | channel; ADCSRA |=( (1<<ADEN) | (1<<
uint16_t ADC_single_con(uint8_t channel,uint8_t anzahl) { DDRC = 0x00; PORTC = 0x00; ADCSRA = ( (1<<ADPS2) | (1<<ADPS1) ); ADMUX = (1<<REFS0) | channel; ADCSRA |=( (1<<ADEN) | (1<<ADSC) ); for(int i=1;i==anzahl;i++)
-
Thread
Interner Pullup Widerstand, Buttonansteuerung klappt nicht
CURSOR_HOME 0x02 // Pinbelegung für das LCD, an verwendete Pins anpassen #define LCD_PORT_4 PORTC #define LCD_DDR_4 DDRC #define LCD_D4 PC0 #define LCD_PORT_5 PORTC #define LCD_DDR_5 DDRC #define LCD_D5 PC1 #define LCD_PORT_6 PORTC #define LCD_DDR_6 DDRC #define LCD_D6 PC2 #define LCD_PORT_7 PORTC #define LCD_DDR_7 DDRC #define LCD_D7 PC3 #define LCD_RS_PORT PORTB #define LCD_RS_DDR DDRB #define LCD_RS PB3 #define LCD_EN1_PORT PORTB #define LCD_EN1_DDR DDRB
-
Thread
Timer soll Variabel löschen in Bascom.
Eingabe As String * 1 Dim Zähler As Byte Dim Länge As Byte Starten: Porta = 0 Portb = 0 Portc = 0 Wait 1 Portc.7 = 1 Empfangen = "" Print " Start " 'Rückmeldungstest '------------------------------------------------ Warten: Namen = Left(empfangen
Paketen Restore Map1 For T = 1 To 73 Read Pixel : Portb = Pixel Waitus 40 Next T Portc.7 = 1 Gosub Lied Portc.7 = 0 '------------------------------------------------ ' Ende nach Zeit '------------------------------------
-
Thread
ADC Wandler PIC16F877A
ADC_VALUE += (ADRESH << 8); if (ADC_VALUE > 500) { PORTC |= 0b00010000; PORTC &= 0b11110111; } else { PORTC |= 0b00001000; PORTC &= 0b11101111; } } } [/c] Denke das sollte funktioneren, tuts aber nicht
was mit der clk zu tun haben könnte. Bitte um Ratschläge Achja es wird kein einziger PIN von PortC gesetzt das heißt des Problem liegt weiter vorne. Danke. mfg PIC-Programmer ;-)
-
Thread
PIC18F4520 - AD Channel wechselt nicht?
PORTA = 0x00; // Initialize PORTA PORTB = 0x00; // Initialize PORTB PORTC = 0x00; // Initialize PORTC PORTD = 0x00; // Initialize PORTD PORTE = 0x00; // Initialize PORTE // ADC Einstellung (DA HATS NOCH WAS bezügl. ACQT usw.?) ADCS0
PORTA = 0x00; // Initialize PORTA PORTB = 0x00; // Initialize PORTB PORTC = 0x00; // Initialize PORTC PORTD = 0x00; // Initialize PORTD PORTE = 0x00; // Initialize PORTE ADCS0 = 0; ADCS1 = 1; ADCS2 = 0; // FOSC
-
Thread
Interrups in Assembler
, die 2 Interrups beinhaltet. INT0 und INT1. Wird der Taster 1 betätigt, soll die Grüne Led an PortC 7 mal Aufleuchten. Wird der Taster 2 betätigt, soll die Rote Led an PortB 5 mal Aufleuchten. Wenn ein Taster Betätigt wird, springt das Programm in ein Unterprogramm, welches mit CLI beginnt und
OUT GICR,R25 ;)Interrupt INT0 und INT1 verbieten SER R20 LDI R21,0x0E Weiter1: OUT PORTC,R20 ldi R17, $16 WGLOOP0: ldi R18, $42 WGLOOP1: ldi R19, $DD WGLOOP2: dec R19 brne WGLOOP2 dec R18 brne WGLOOP1 dec R17 brne WGLOOP0
-
Thread
Atmega Taster einlesen und in Register schreiben funktioniert nicht wie geplant
<<PA1)) && (PINB & (1<<PB1)) ) ) {PORTB &= ~(1<<PB1);} else {PORTB &= ~(1<<PB1);} PORTC = PIND; } [/c] Was genau mache ich falsch?
PINB & (1<<PB7)) ) ) {PORTB &= ~(1<<PB7);} else {PORTB |= (1<<PB7);} */ PORTC = PINB; } return 0; } int mode_select() { int mode_select_sw; mode_select_sw = (PIND & 0xf0) >> 4; //read portd,filter out pin 4-7(last 4 bit, high-byte), //store in
-
Thread
eigentümliches Verhalten eines Übungsprog. in Asm.
----------------------- mainloop: wdr sbis ioPIND,2 ;Taster offen rjmp end cbi ioPORTC,0 ;Led aus rjmp raus end: sbi ioPORTC,0 ;Led an raus: rjmp mainloop ;------------------------------------------------------------------------ onTC0: cli ;Interrupts sperren push
so aussehen: mainloop: sbis ioPIND,2 ;Taster offen? rjmp led_an ;ja cbi ioPORTC,0 ;nein: LED aus rjmp mainloop_end led_an: sbi ioPORTC,0 mainloop_end: rjmp mainloop > ; Takt : 3,6864 MHz > .equ F_CPU, 1000000 Das widerspricht sich fürchterlich, das
-
Thread
Brauche Hilfe bei Grundlagen: 16-Segment Anzeige
und nicht im Hauptprogramm? { PORTB=sign[zeichen-32]: //welchen Wert hat ''zeichen"? PORTC=(sign[zeichen-32]>>8); } int main() { int8_t i; DDRB = 0xFF; DDRC = 0xFF; for(i=0;i<=58;i++) { PORTB = sign[i]; PORTC = (sign[i] >>
char_out (text[i]); delay_ms(700); i++; PORTB=0; PORTC=0; delay_ms(50); } } } [/c] Ich komme mir gerade extrem dumm vor, da ich kaum etwas verstehe, aber im Buch waren vorher nur ganz grundlegende Dinge
-
Thread
Atmega16 LED leuchtet stat blinkt
hier jemand helfen? hier ist der Code für die LEDs: int main(void) { DDRC = 0xFF; //Makes PORTC as Output while(1) //infinite loop { PORTC = 0x01; _delay_ms(200); PORTC = 0x03; _delay_ms(200); PORTC = 0x07; _delay_ms(200); PORTC= 0x00; //Turns OFF All
-
Thread
Problem mit PWM aus Timer2 mit ATmega8535
wie ich? Ich habs gestern stundenlang probiert. PIND7 wird auch von nichts anderem verwendet. PORTA/PORTC werden komplett als Outputs konfiguriert und für die LCD-Ansteuerung benutzt, aber erst deutlich später im Code... Wie weiter oben erwähnt, hatte ich für OCR2 Werte wie 0, 1, 2, 4, 128 ausprobiert
r19 .def counter=r20 .def lcd_page=r21 .equ FREQ=7372800 .equ TIME50MUS=123 .equ LCD_COMMAND_PORTC=0b00001110 .equ LCD_DATA_PORTC=0b00001111 .equ A0=0 .equ CS2=1 .equ CS1=2 .equ READ=3 .equ WRITE=4 ; Steuer-Pins: ; PC0: A0 (0: Command, 1: Data) ; PC1: CS2 (0: right display active
-
Thread
Software UART Empfang (ATmega8)
auf einem ATmega8 - mit einem Software-UART Daten von einem anderen ATmega8 zu empfangen und auf PortC auszugeben, allerdings kommt nur Kauderwelsch raus. Die Baudrate ist genau ein Timer durchlauf mit Vorteiler 1024, bei 16 MHz Takt. Also sehr sehr langsam. Hier der Code: void init_SoftUART(
001111 Ich glaub aber nicht, dass du daraus schlau wirst. Ich hab nur immer die ersten 6 Bits da PortC nicht mehr Pins hat.
-
Thread
ATMEGA reagiert nicht auf Taster
$hwstack = 32 $crystal = 1000000 Config Portb = Output Config Portc.0 = Input Portc.0 = 1 Taste Alias Portc.0 Do If Taste = 0 Then Portb.1 = 0 Else Portb.1 = 1 End If Loop End [/code]
Mega32 + Probleme mit dem Port C -> JTAG per Fuse abschalten (JTAGEN) > Taste Alias Portc.0 Taste Alias Pinc.0 Dein jetziger Alias frägt ab, ob der Pullup eingeschaltet ist.
-
Thread
Schon wieder ein Timerproblem.
avr/io.h> #include <avr/interrupt.h> volatile unsigned long millis; int main(void) { PORTC |= ((1<<5)|(1<<4)|(1<<3)); DDRC |= ((1<<5)|(1<<4)|(1<<3)); TCCR0A |= (1<<WGM01); TCCR0B |= (1<<CS01)|(1<<CS00); TIMSK0 |= (1<<OCIE0A); OCR0A = 125; sei(); while (1)
Christian T. schrieb im Beitrag #4394517: > cli(); > PORTC ^= ((1<<5)|(1<<4)|(1<<3)); > millis=0; > sei(); cli und sei haben in der Interruptroutine nichts verloren, das wird automatisch gemacht
-
Thread
Problem mit einfachem Taster
simulieren, indem ich vorerst den PIN mit Masse verbinde. Schalter sollen an die Pins 0, 1 und 2 von PORTC kommen. Ich verwende folgende selbstgeschrieben Routinen: void initPortCin() { DDRC &= ~(_BV(0)|_BV(1)|_BV(2)); //PortC als Eingang PORTC |= _BV(0)|_BV(1)|_BV(2); //PullUp Widerstände
Sorry, Nachtrag: Ich erwarte, dass alle High sind weil ich jetzt setze: DDRC=0x00; PORTC=0xFF;
-
Thread
AD Wandler am AT90S2313
Bascom-Befehlen Low und High auf die zwei Bytes zugreifen, aus denen Deine Variable besteht. Portc = High(Variable) Portc = Low(Variable) ... ob das so sinnvoll ist, hängt von Deiner Hardware ab. Angenommen, ein FT245 wird verwendet und hängt an Portc, musst Du nach jedem Anlegen eines Bytes an Portc noch einen Schreibstrobe für den FT245 erzeugen (Pin /WR auf Low, warten, Pin /WR auf High) und natürlich dessen Fifofüllstand testen (Pin /TXE testen). Aber das beschreibt das Datenblatt des FT245
-
Thread
Pinabfrage ATMEGA
{ PORTD ^= (1<<PD6); //Toggel Augang PD6 if (!(PORTC & (PINC0))) //Pinabfrage PC0 = 0 { PORTD &= ~(1<<PD7); //LED einschalten } if (PORTC & (PINC0)) //Pinabfrage PC0 = 1 { PORTD |= (1<<PD7); //LED ausschalten
> if (!(PORTC & (PINC0))) //Pinabfrage PC0 = 0 > if (PORTC & (PINC0)) //Pinabfrage PC0 = 1 PIN - Abfrage!
-
Thread
Problem Zufallsgenerator
.equ IPB=PINB .equ IPC=PINC .equ IPD=PIND .equ OPA=PORTA .equ OPB=PORTB .equ OPC=PORTC .equ OPD=PORTD .equ DRA=DDRA .equ DRB=DDRB .equ DRC=DDRC .equ DRD=DDRD // Datenrichtungsregister definieren sbi DRD,5 sbi DRD,6 cbi DRD,2 // Hauptcode rjmp binaer0 binaer0
.equ IPB=PINB .equ IPC=PINC .equ IPD=PIND .equ OPA=PORTA .equ OPB=PORTB .equ OPC=PORTC .equ OPD=PORTD .equ DRA=DDRA .equ DRB=DDRB .equ DRC=DDRC .equ DRD=DDRD // Datenrichtungsregister definieren sbi DRD,5 sbi DRD,6 cbi DRD,2 // Hauptcode rjmp binaer0 binaer0
-
Thread
LED-Matrix -> Multiplex und jetzt PWM?
umgebaut. Verwendet wird ein Atmega32 mit 8mhz intern. [CODE] ISR(TIMER2_COMP_vect) { PORTC = 0xFF; // Turn all cathode layers off. (all transistors off) PORTA = 0x00;//Turn off output PORTA = cube[current_layer]; //Load bytes unsigned char CUBE[8] PORTC ^= (1 << current_layer);
DATA bus output DDRC = 0xff; // Layer select output PORTA = 0x00; // Set data bus off PORTC = 0x00; // Set layer select off OCR2 = 10; // interrupt at counter = 10 TCCR2 |= (1 << CS20) | (1 << CS22); // Prescaler = 128. TCCR2 |= (1 << WGM21); // CTC mode. Reset counter when
-
Thread
LCD kann nur Kontrast einstellen
Datenbus DB4-DB7, das unterste Bit DB4 kann auf den Portbits 0..4 liegen // LCD DB4-DB7 <--> PORTC Bit PE4-PE7 #define LCD_DB PE4 // LCD Steuersignale RS und EN // LCD RS <--> PORTC Bit PG0 (RS: 0=Data, 1=Command) #define LCD_RS PG0 // LCD EN <--> PORTC
-
Thread
Starterkit ATmega8: Blink-Projekt, Anfänger Problem :(
Hallo, wo hast du das Programm her? Tausch mal bei deinem Programm PORTB gegen PORTC und (1<<PB2)|(1<<PB3) gegen (1<<PC5) aus. Die LED hängt an PC5. Anbei Die Bedienungsanleitung, Schaltplan und Beispiel Programm zu DEINEM Board. Für weitere Infos siehe http://www.olimex.com Achtung
> int main(void) { DDRC |= (1<<PC5); while(1) { PORTC |=(1<<PC5); _delay_ms(1000); PORTC &=~(1<<PC5); _delay_ms(1000); } }[/c] Könnte wohl passen? Hast dich wohl irgendwo verklickt? Viel Spass beim Programmieren. Gruß onifred
-
Thread
ATmega 1284P EA DIP122 LCD Steuerung
if(side==1) { CMD_PORT |= (0<<LEFT_DISPLAY); CMD_PORT |= (1<< RIGHT_DISPLAY); } PORTC |= (1<<PC1); CMD_PORT |= (0<<C_D_PORT); LCD_DATA_BUS = cmd; _delay_us(COMMAND_DELAY_US); CMD_PORT |= (0<<LEFT_DISPLAY|0<<RIGHT_DISPLAY); LCD_DATA_BUS = 0x00; PORTC |= (0<<PC1); }
Als Anmerkung: PortC ist nur zum Debuggen, dort befindet sich eine Rote und grüne LED für Daten bzw. Befehl.
-
Thread
Atmega8 Soft PWM Verständnis
ISR(TIMER1_COMPA_vect) { t++; if (t==3) { t=1; } if (t==1) { PORTC = 0x00; //LED an; } else if (t==2) { PORTC = 0xff; //LED aus; } TCNT1 = 0; //Zähler nullen } int main(void) { DDRC = 0xff; PORTC = 0xff; TCCR1A
-
Thread
Register miteinander vergleichen - Assambler - my avr
" TEMPO2: sbi PORTC,4 ;Motor an push r24 ;Inhalt von Register r24 kellern push r25 ;Inhalt von Register r25 kellern push r26 ;Inhalt von Register r246 kellern ldi r26,0x01 ;0x10 ins Arbeitregister
r25 ;Inhalt von Register r25 entkellern pop r24 ;Inhalt von Register r24 entkellern cbi PORTC,4 ;Motor aus rjmp main ;-----------------------------------------------------------------------
-
Thread
Probleme mit der lcd.c von Ullrich Radig
declaration of function 'cbi' ../Abschlussprojekt/Programmcode/LCD/SourceCode1.0/lcd.c:59: error: 'PORTC' undeclared (first use in this function) ../Abschlussprojekt/Programmcode/LCD/SourceCode1.0/lcd.c:63: warning: implicit declaration of function 'sbi' ../Abschlussprojekt/Programmcode/LCD/SourceCode1.0
first use in this function) ../Abschlussprojekt/Programmcode/LCD/SourceCode1.0/lcd.c:85: error: 'PORTC' undeclared (first use in this function) ../Abschlussprojekt/Programmcode/LCD/SourceCode1.0/lcd.c:100: error: 'PINC' undeclared (first use in this function) ../Abschlussprojekt/Programmcode/LCD/SourceCode1.0
-
Thread
ILI9486L in Betrieb nehmen
); _delay_ms(2); PORTD |= (1<<RDX); _delay_ms(2); } void setData(uint16_t *Data){ PORTC = (*Data & 0xff); PORTA = ((*Data >> 8) & 0xff); }[/c]
PORTG &=~ (1<<WRX); setData(Data); PORTG |= (1<<WRX); } void setData(uint16_t Data){ PORTC = (Data & 0xff); PORTA = ((Data >> 8) & 0xff); }[/c]
-
Thread
Amega8 Kommunikation mit Interrups
des Aufrufs von Timer1_An() entspricht SOI void Timer1_AN(void) { Timer1_WriteTCNT1(); //PORTC = 0b00000000; PORTC = (0 << PC0); TCCR1B = (1<<CS10); //kein prescale verwenden TIMSK = (1<<TOIE1); //Interrupt für Timer1 enable sei(); //globale Interrupts enable
} void Timer1_AUS(uint16_t anzSchritte) { TCCR1B = (0<<CS10); //Timer1 aus //PORTC = 0b11111111; //Ausgang PortC PORTC = (1 << PC0); for(int i = 0; i < anzSchritte; i++) { _delay_ms(10); //Wartezeit midestens 10 ms } } ISR(TIMER1_OVF_vect) { Timer1
-
Thread
HC-SR04 Ultraschallsensor + 7-Segment Anzeigen Problem mit Ausgabe wenn kein Objekt detektiert wird
PORTA = segment7[messwert/10]; //10er, LED-Segment mitte messwert = messwert % 10; // 0 .. 9 PORTC = segment7[messwert]; //1er, LED-Segment rechts [/c]
% 100; PORTA = led2[messwert/10]; //10er, LED-Segment mitte time = messwert % 10; PORTC = led1[messwert]; //1er, LED-Segment rechts [/c] gar nicht funktionieren! Angenommen messwert ist zu Beginn 123. messwert/100 ist dann 1 messwert/10 ist dann 12 >>> PORTB = led3[1
-
Thread
Taster und LED
DDRD &= ~(1 << 2); //Eingang // PORTD |= (1 << 2); //Pull-Up aktivieren int i; i = 0; PORTC &= ~(1 << PC5); while(1) { if ( !(PIND & (1<<PIND2)) ) { if(i<1) { i = 1; PORTC |= (1 << PC5); _delay_ms(250); } else { i = 0; PORTC &= ~(1 << PC5); _delay_ms(250); } } } return 0; } Gruß, Tobi
-
Thread
Hilfe bei vermeintlich einfachem Basic Programm
Byte Dim Var_rv3029_years As Byte Dim Alle_register(50) As Byte Weekday = 2 Sda_port Alias Portc.1 Scl_port Alias Portc.0 Config Twi = 400000 Const Rv3029_write = &B10101100 'Adresse des DS1307 = &HD0 (schreiben) Const Rv3029_read = &B10101101 'Adresse des DS1307 = &HD1
Var_rv3029_weekdays = 5 Var_rv3029_months = 5 Var_rv3029_years = 15 Weekday = 2 Config Scl = Portc.0 Config Sda = Portc.1 Config Twi = 400000 Const Rv3029_write = &B10101100 'Adresse des DS1307 = &HD0 (schreiben) Const Rv3029_read = &B10101101 'Adresse des DS1307 = &HD1
-
Thread
datei erstellen und an sd karte senden
SD-Card folgendermaßen initialisiert: [c] test.spiStop();//ethernet aus //sbi(DDRC,6); sbi(PORTC,6); //SS port der SD karte //////// sdCard-init /////////////// ok=sdCard.config(); while(!ok) { sbi(DDRC,5);sbi(PORTC,5); // LED rot DebugPrintFlash("FEHLER: bei MicroSD-Card Initialisierung\n"); ok = sdCard.config(); } cbi(DDRC,5); cbi(PORTC,5); //rote LED aus sbi(DDRC,4); sbi(PORTC,4); //grüne LED an [/c] Das funktioniert scheinbar auch, denn wenn ich die Karte draußen lasse bleibt die LED auf Rot und wenn sie drinnen ist dann
-
Thread
Atmega8 UART ext. Quarz
-----------Hauptprogramm------------------- int main(void) { DDRC=0x0F; // alle Pins an PortC als Ausgänge DDRD=0x04; // alle Pins an PortD als Ausgänge DDRB=0xFF; // alle Pins an PortD als Ausgänge USART_init(UBBR_Value); USART_Flush(); sei(); while(1) { //PORTC = 0x00; //data=USART_Receive(); //USART_Transmit(data); //PORTC = data; PORTD ^= ( 1 << PD2 ); } } //-------------------ISR------------------- ISR(USART_RXC_vect) { ///* if (Auswahl == 0) { data=USART_Receive(); } if
-
Thread
Atmega2560 8 Bit Steuerung LCD
Im db steht, wie man das LCD AN/AUS schaltet, habe probiert es mit gcc zu realisieren: PORTC |= (1 << 2); // E PORTC &= ~(1 << 0); // RS PORTC &= ~(1 << 1); // RW PORTA &= ~(1 << 7); PORTA &= ~(1 << 6); PORTA &= ~(1 << 5); PORTA &= ~(1 << 4); PORTA |= (1 << 3)
-
Thread
Mit Auslagerung funktionierts nicht mehr
PC4 #define LED6 PC5 #define LED7 PC6 #define LED8 PC7 #define LED PORTC //Allgemeine Variable volatile uint8_t timer; volatile uint8_t timer_m; volatile uint8_t taster; volatile uint16_t halt; ISR(TIMER0_OVF_vect) { /* Interrupt Aktion alle (
} //Hauptprogram int main(void) { //Ein - Ausgänge Definieren DDRC = 0xff; //PORTC Ausgang PORTA = 0xff; //PORTA Pullup aktivieren // Timer 0 konfigurieren TCCR0 = (1<<CS01)| (1<<CS00); // Prescaler 64 // Overflow Interrupt erlauben TIMSK |= (1<<TOIE0); //
-
Thread
8-Bittimer und Interrupts :(
delay.h> volatile int zahler, sek; main() { //Timer 0 konfigurieren DDRC = 0x0F; //definiert portC ping 0-3 als ausgang PORTC = 0x0F; //setzt die ausgänge 0-3 vom port C auf logisch 0 TCCR0 = (1<<CS00) | (1<<CS02); //1024er prescaler TIMSK|=(1<<TOIE0); //timer overflow interrupt sei(); //Globale Interrupts aktivieren while(1) { PORTC=sek; _delay_ms(200); } } ISR(TIMER0_COMP_vect) { zahler +=159; if(zahler >=10000) {sek++; zahler -= 10000;} } [/c]
-
Thread
Lärm erkennen
~(1<<ADEN); // ADC deaktivieren (2) } int main() { if ( adcval > adcvalmax){ PORTC = 0xFF; } // wenn threshold überschritten wird PORTC auf high schalten } [/c] Mfg, Peter
>int main() { > if ( adcval > adcvalmax){ PORTC = 0xFF; } // wenn threshold überschritten >wird PORTC auf high schalten >} Und immer wieder den Reset Knopf drücken ;)
-
Thread
ATMega128 stürzt ab nachdem man Interrupts einschaltet.
unsigned int i; ISR( TIMER0_OVF_vect ) { Counter++; if( Counter == 10000 ) { i++; PORTC=(1<<i); if (i==7) i=0; Counter = 0; } } int main() { Counter = 0; DDRA=0xff; DDRB=0xFF; DDRC=0xff; PORTA=0x01; PORTB=0x01; PORTC=0; TCCR0 = ( 1 <<
// Interrupts an while( 1 ){} } [/c] Dieses soll einfach nur den PortC der Reihe nach durchschalten. Bei Debuggen passiert folgendes (Ich gehe mit F11 Schritt für Schritt jede Zeile durch): Programm läuft bis zum sei();. Drücke ich dann ein weiteres Mal F11 bleiben
-
Thread
ATMEAG16 macht Resets
//Ausgänge setzen: PC0-PC7+PA6+PA7 DDRC = 0xff; DDRD |= (1 << DDD6) | (1 << DDD7); PORTC= MCUCSR; /* //alle Ausgänge auf low... PORTC= 0x00; */ PORTD |= (1 << PD6) | (1 << PD7); _delay_ms(1000); PORTD &= ~(1 << PD6) | (1 << PD7); _delay_ms(1000); PORTD |= (1 << PD6
tun müssten - das versteh ich nun wieder überhaupt nicht, da stimmt doch was nicht... Die leds an PORTC und PORTD sind über 330Ohm auf masse. thx für eure antworten mixblick Leo
-
Thread
LCD ausgabe mit AVR Studio
by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions. * */ #define LCD_PORT PORTC /**< port for the LCD lines */ #define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */ #define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */ #define LCD_DATA2
und nach meiner meinung hängen E und R/W doch garnicht am gleichen port. für das obere ist immer PORTC (R/W ist an port C pin 5) und E hängt am port B pin 5. jan
-
Thread
_delay_ms() Atmega8 C
1000000 #include <avr/io.h> #include <util/delay.h> void Initialisieren() { DDRC = 0xff; PORTC = 0xff; } void Status (unsigned char state) { switch (state) { case 1: PORTC = 0xff; PORTC = ~(1<<PC3); break; case 2: PORTC &= ~(1<<PC2); break; case 3: PORTC = ~(1<<PC1); break; case 4: PORTC = ~(1<<PC2); break; } } int main() { Initialisieren(); while(1) { Status(1); _delay_ms(10000);
-
Thread
befehl nach jedem 25ten Element der If Schleife
ich, ich mache es einfach mit delay, aber dadurch wird die ganze schleife verzögert. [c] PORTC |= (1 << PC5); _delay_ms(250); PORTC &= ~(1 << PC5); _delay_ms(100);[/c] also dachte ich mir, ich mache es so, dass bei jedem 25ten Element die LED angeht und nach 50 Elementen ausgeht
an. [c]ICR1 = 0x4E20; // Periodendauer OCR1A = 100; // High-Pegel dauer PORTC |= (1 << PC5); // LED AUS for (i = 0; i < 1400; i++) { OCR1A = OCR1A+1; _delay_ms(10); if (i==25) PORTC &= ~(1 << PC5); // LED AN } while( 1 ) ; }[/c]
-
Thread
AVR Mega 8, Capture-Match und Overflow Interrupt für Soft PWM
OCR1A=COMPARE; sei(); while(1); } ISR (TIMER1_OVF_vect) { TCNT1=VORLADEWERT; PORTC=0x00; } ISR (TIMER1_COMPA_vect) { PORTC=0xFF; } Gruß, Tom
1<<OCIE1A)|(1<<OCIE1B)); sei(); while(1); } ISR (TIMER1_COMPB_vect) { PORTC=0x00; } ISR (TIMER1_COMPA_vect) { PORTC=0xFF; }
-
Thread
Anzeige einzelner Zahlen verstellbar
Batterielaufzeit heisst LCD mit statischer Ansteuerung, angenommen man packt die Ziffern an PPTA,PORTB und PORTC und Backplane an PORTD.0, und die Taster an PORTD.1 bis PORTD.6 an einen Schalter der die Verbindung nach GND aufhebt dann ist das Programm einfach [code] void setup() { DDRB=DDRA=DDRC=0xFF
) c=0; if(pressed&64) c--; if(c<0) c=9; PORTA=segments[a]^xor; PORTB=segments[b]^xor; PORTC=segments[c]^xor; PORTD.0=!PORTD.0; xor=~xor; pressed=tasten; delay(10); } [/code] Segments ist die übliche 7-Segment Tabelle
-
Thread
SPI unstabil
buf[17]; SPIInit(); TWIInit(); lcd_init(); DDRC |= 0x08; //Hintergurndbeleuchtung PORTC &= ~0x08; //aus buf[16] = 0; //absicherung, um ein unabgeschl. Array zu vermeiden sei(); while(1){ i++; } return 0; } void SPIInit(void){ DDRB &= ~0x2C; //SCK
case 4: lcd_set_cursor(buf[0]-40, buf[1]-40); break; case 5: PORTC |= 0x08; //Hintergrundbeleuchtung an break; case 6: PORTC &= ~0x08; //Hintergrundbeleuchtung aus break; default: lcd_string("SPI-ERROR!!"); } bufpos