$regfile = "xm256a3udef.dat"
$crystal = 32000000
$hwstack = 64
$swstack = 64
$framesize = 256
$lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014
Const Comport = 2
Config Osc = Enabled , 32khzosc = Enabled , 32mhzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
'Switch on DFLL (Both 32M and 2M, see Errata for 128A1
Osc_dfllctrl.0 = 0 'Internal 32kHz
Osc_dfllctrl.1 = 0 'Internal 32kHz
Dfllrc32m_ctrl.0 = 1 'On
Dfllrc2m_ctrl.0 = 1 'On
Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled
'#*********************** PORTA ************************************************
Config Porta = Input
'#*********************** PORTB ************************************************
Config Portb = &B0000_1110
'#*********************** PORTC ************************************************
Config Portc = Input
'*********************** PORTD *************************************************
Config Portd = &B10110001
'Infrared Receiver
Config Xpin = Portd.1 , Outpull = Pullup , Sense = Falling ' Pullup on IR-Receiver
Config Rc5 = Pind.1 , Wait = 2000
'#*********************** PORTE ************************************************
Config Porte = &B01011000
Config Xpin = Porte.5 , Outpull = Pullup , Sense = Both
Config Com5 = 38400 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Open "COM5:" For Binary As #1
'#*********************** PORTF ************************************************
Config Portf = &B00001000
Config Com7 = 9600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Open "COM7:" For Binary As #2
Dim Adress As Byte , Command As Byte
Enable Interrupts
Do
Print #comport , "waiting for RC5..."
Do
Getrc5(adress , Command)
If Adress = 0 Then
Command = Command And &B0111_1111
Print #comport , Adress ; " " ; Command
End If
Loop Until Command = 9
Loop
End |