Hall!
Hier ist der code.
Könnt ihr mir sage wie das mit dem ADC Interrupt geht?
ich meine so ähnlich wie "On Int0 tue_irgendwas", denn in der neuen Bascom Hilfe habe ich leider nichts gefunden.
Grüße Viktor
Code:'############################################################################### '##### '##### Project: 6A-Netzteil '##### Version: v1.0 '##### Date: 10.03.2007 '##### Projectname: 6A_Netzteil_v1.0.bas '##### Developer: Krieger, Viktor '##### '############################################################################### '########[ Description ]########################################################### '####PORT A#### ' PA0 = [ADC CH0] CONTROL_SPL ( voltage control 12V ) ' PA1 = [ADC CH1] PWR_SPL (voltage control 33,6V ) ' PA2 = [OUT] LED_ERR (Error LED) signals an error of the power-supply ' PA3 = [OUT] LED_SDWN (Shut Down LED) signals powerdown - state ' PA4 = [OUT] LED_RDY (Ready LED) signals that all ok ' PA5 = [OUT] NC this pin is not connected ' PA6 = [OUT] REL_POWON ' PA7 = [OUT] REL_PROTECT '####PORT B#### ' ' PB0 = [DEF] MOSI * ' PB1 = [DEF] MISO * ' PB2 = [DEF] SCK * ' PB3 = [IN] JP1 jumper 1 ' PB4 = [IN] JP2 jumper 2 ' PB5 = [OUT] ERROR signals other devices an error (no error = 1/ on error = 0) ' PB6 = [IN] SDWN input for standby sequence (active 0) ' PB7 = [DEF] RESET * ' ' * Default configuration of the portpin's by using of hardware SPI !!! '############################################################################### $regfile = "at26def.dat" $crystal = 8000000 $hwstack = 32 $swstack = 16 $framesize = 24 '########[ Hardware Configuration ]################################################# ' Configurate ADC's ' Single - as single ended inputs ' Auto - for the fastest possible samplingrate ' Internal - set Vref @ 2,56V Config ADC = Single , Prescaler = Auto , Reference = Internal ' Cofigurate Interrupts Config Int0 = Low Level ' coonfigurate Int0 at Low Level On Int0 ISR_Int0 ' jump to ISR_Int0 label ' Enable Global Interrupts Enable Interrupts 'enable all Interrupts Enable Int0 'enable Interrupt Int0 ' Port's Directions & PullUp's DDRa = &B1111_1100 ' configurate I/O's 1-OUT/ 0-IN DDRb = &B0010_0000 ' configurate I/O's 1-OUT/ 0-IN PORTa = &B0000_0000 ' internal PullUps 1/0 on/off PORTb = &B1100_0000 ' internal PullUps 1/0 on/off ' Output's PORT A LED_ERR Alias PORTa.2 LED_SDWN Alias PORTa.3 LED_RDY Alias PORTa.4 REL_POWON Alias PORTa.6 REL_PROTECT Alias PORTa.7 ' Input's PORT B JP1 Alias PINb.3 JP2 Alias PINb.4 SDWN Alias PINb.6 ' Output's PORT B ERROR Alias PORTb.5 '########[ Constants ]############################################################# Const PowerUp_Delay = 25 ' const x 100ms = powerup delay time [ms] Const minThresoldCh0 = 690 ' 690 Const minThresoldCh1 = 700 ' 700 '########[ Variables ]############################################################# Dim Overload_Flag As Bit Dim Value_Ch0 As Word Dim Value_Ch1 As Word '########[ Initialisation ]########################################################### Overload_Flag = 0 Gosub LED_TEST Gosub POWER_UP '########[ Main Code ]############################################################ Main: Do Value_Ch1 = GetAdc(1) Waitms 10 Value_Ch1 = GetAdc(1) Waitms 10 Value_Ch0 = GetAdc(0) Waitms 10 Value_Ch0 = GetAdc(0) Waitms 10 If Value_Ch0 < minThresoldCh0 Then GoSub OVERLOAD EndIf If Value_Ch1 < minThresoldCh1 Then GoSub OVERLOAD EndIf Loop End '########[ Subroutines ]########################################################### LED_Test: LED_ERR = 0 LED_SDWN = 0 LED_RDY = 0 Waitms 1000 LED_ERR = 1 LED_SDWN = 1 LED_RDY = 1 Return Power_Up: Dim i As Byte Start Adc LED_RDY = 0 REL_PROTECT = 1 Do Toggle LED_RDY Waitms 100 Incr i Loop Until i = PowerUp_Delay REL_POWON = 1 Waitms 100 REL_PROTECT = 0 LED_RDY = 0 Goto MAIN Power_Down: Stop Adc LED_RDY = 1 LED_SDWN = 0 REL_POWON = 0 Do Waitms 400 Toggle LED_SDWN Loop Until SDWN = 1 LED_SDWN = 1 Return Overload: Overload_Flag = 1 REL_POWON = 0 REL_PROTECT = 0 LED_RDY = 1 LED_ERR = 0 Do Toggle LED_ERR Waitms 1000 Loop Return '########[ ISR Routines ]########################################################## ISR_Int0: Disable Int0 If Overload_Flag = 1 Then Gosub OVERLOAD EndIf Gosub POWER_DOWN Enable Interrupts Enable Int0 Gosub POWER_UP End







Zitieren

Lesezeichen