Microwave Forum

Sämtliche Inhalte dieses Forums dienen ausschließlich wissenschaftlichen und nichtkommerziellen Zwecken --- All content is provided for educational and non commercial purposes only
 
You are not logged in.
LoginLogin Join for freeJoin for free
MessagesMessages MembersMembers SearchSearch HelpHelp StatStatistics
VotesVotes FilesFiles CalendarCalendar BookmarksBookmarks

First   Previous   Next   Last
Author Message
kleiner-onkel

Administrator

Beiträge: 412


New PostCreated: 2008-12-30, 06:19 PM CET     Subject: Re: MOTOROLLA 68HC12 Reply with Quotation  

Eve und der letzte Engländer
zudem muss ich noch für die Schule den HC12 programmieren,.. und das mit Visual Studio 2008... das Programm ist zimlich kompliziert für Anfänger.

Schon so ein kleiner blinker ist da ganzschön kompliziert


#include "hc12.h"
#include "dbug12.h"

// Funktionprototyping
extern void _Startup( void ); // externe Start-Funkt.
void initTimer (void);
void Tim_Ch7_ISR(void);

unsigned char i=0;

// Hauptfunktion
void main()
{
COPCTL=0x00; // Watchdog deaktivieren
DDRB=0xFF; // Port B als Ausgang setzen
PORTB=0xFF; // LED's ein
initTimer();

asm CLI;
while(1); // Endlosschleife
}

// Timer initialisieren
void initTimer(void)
{
TSCR=0x80; // Timer aktivieren
TIOS=0x80; // TC7 als output compare
TMSK2=0x0B; // Timer Reset mit TC7 + Prescaler einstellen (8 -> 1µs)
TMSK1=0x80; // Interrupt für TC7 aktiviert
TC7=10000; // TC7=10000
TFLG1=0x80; // Interruptflag für TC7 löschen
}

// TC7 ISR
#pragma TRAP_PROC
void Tim_Ch7_ISR(void) // wird alle 10ms aufgerufen
{
setbit(TFLG1,bit7); // Interrupt-Flag für TC7 löschen
++i;
if (i>111)
{
i=0;
PORTB^=0xFF; // Bitweise XOR
}
}

// Vektor-Tabelle
// Bei Bedarf "0" mit ISR-Funktionsname ersetzen
#pragma CONST_SEG VECTORS
void (* const VectorTable[])() =
{
0, // SBI General
0, // SBI Synchron
0, // SBI Receive
0, // reserved
0, // reserved
0, // reserved
0, // Receive Fifo
0, // ATD
0, // reserved
0, // SCI
0, // SPI
0, // Pulsakkumulator Eingangsflanke
0, // Pulsakkumulator Überlauf
0, // Timer Überlauf
Tim_Ch7_ISR, // Timer Kanal 7
0, // Timer Kanal 6
0, // Timer Kanal 5
0, // Timer Kanal 4
0, // Timer Kanal 3
0, // Timer Kanal 2
0, // Timer Kanal 1
0, // Timer Kanal 0
0, // Real Time Interrupt
0, // IRQ
0, // XIRQ
0, // Software Interrupt
0, // TRAP Illegal Opcode
0, // COP Watchdog
0, // Clock Monitor
_Startup // Hauptprogramm
};



nach oben
Show user's profile Send private message to this member Go to website of this member
Change sort:  
First   Previous   Next   Last
Page 6 of 54
Go to:   
Search

powered by carookee.com - group communication for you

Layout © subBlue design