Bascom Version 1.11.8.1 and 1.11.8.3
Ich habe beim Projekt Bascom Datalogger mit dem Butterfly vier Bugs im Zusammenhang mit den Registern des ATmega169 festgestellt.
' Config Spi = ...
' Config Clock = Soft
' Powersave
' Clockdivison
Diese sind alle im Quelltext dokumentiert.
siehe https://www.roboternetz.de/phpBB2/viewtopic.php?t=23231
anbei die vier Code-Ausschnitte mit den Workarounds
' Config Spi = ...
' Config Clock = SoftCode:'!!!there is a bug in Bascom SPI I/O-Routine with "Config Spi ..." 'M169: Bascom checks a wrong Register, not the SPI Interrupt Flag SPSR.SPIF 'Config Spi = Hard , Interrupt = Off , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1 'SPI double speed settings Spsr = &B00000001 'Enable SPI in Master mode, mode 3, Fosc/4 Spcr = &B01011100
Code:'!!!Bascom BUG in Timer-Interrupt 'M169: the Bascom-Statement "Config Clock = Soft" set the false Interrupt Timer0 'you can correct this Bascom-ERROR with two extra code lines: ' Timsk0.toie0 = 0 'Disable Timer0 Overflow Interrupt ' Timsk2.toie2 = 1 'Enable Timer2 - Timer/Counter2 Interrupt '...but we use Async Timer with Bascom-Softclock as workaround 'its easy to extend the SUB _soft_clock (mcs.lbx) -> "$external _soft_clock" Config Clock = User 'Async, Timer2-Interrupt, 'don't use the alternative "Clock = Soft,GOSUB = SECTIC" its stress the hwstack with extra 30 Byte (Push/Pop) '...schnipp... '*********ISR Timer2 - Async ************************************************** '--------------------------------------------------------------- 'Interrupt: Isr_softclock 'Call from: Interrupt Vector Timer2 'Forward to: Bascom internal ISR _Soft_Clock 'Purpose: increment RTC: clock and date ' external 32kHz Oscillator (Async Modus) 'Result: _sec, _min, _hour, _day, _month, _year '--------------------------------------------------------------- $external _soft_clock Const _sectic = 0 'Compilerstatement for CONFIG CLOCK = USER , GOSUB <> SECTIC Isr_softclock: $asm PUSH R24 'save used registers IN r24, SREG PUSH R24 LDI R24, 1 sts {Timer_Key_Event},R24 'variable for detect a new second 'If _sec = 0 Then Incr Powersavetimer LDS R24, {_sec} 'Load direct from data space CPI R24,0 'Compare with immediate BRNE no_timer_incr 'Branch if not equal LDS R24, {Powersavetimer} SUBI R24,&HFF 'incr Auto Power Down timer one minute sts {Powersavetimer},R24 No_timer_incr: POP R24 'get content of SREG !OUT SREG, R24 POP R24 'internal Bascom ISR-Routine: Softclock JMP _SOFT_CLOCK 'original RETI $end Asm Return 'unused dummy RETI
' Powersave
' ClockdivisonCode:'***SLEEP*** ldi r24, 7 'PowerSave Modus !Out Smcr , R24 Enable Interrupts sleep
Code:$crystal = 1000000 'only Bascom internal 'now set register Clkpr to 1 Mhz 'RTFM: First, set first *only* Clock Prescaler Change Enable... Clkpr = &H80 'Clkpce LDI R24,&B0011 'Clkps1&Clkps0 STS Clkpr,R24 '...then (max. 4 Clocks!) prescaler = 8, Inter RC 8Mhz / 8 = 1Mhz







Zitieren
Lesezeichen