mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Merge pull request #64 from vDorst/fix_systick_calc
Fix systick 16-bit writing to timer0 registers.
This commit is contained in:
@@ -97,3 +97,7 @@ __sfr __at(0xb4) SFR_NIC_DATA_H;
|
|||||||
__sfr16 __at(0xb6b5) SFR_NIC_RING_U16LE;
|
__sfr16 __at(0xb6b5) SFR_NIC_RING_U16LE;
|
||||||
__sfr __at(0xb5) SFR_NIC_RING_L;
|
__sfr __at(0xb5) SFR_NIC_RING_L;
|
||||||
__sfr __at(0xb6) SFR_NIC_RING_H;
|
__sfr __at(0xb6) SFR_NIC_RING_H;
|
||||||
|
|
||||||
|
/* Standard 8051 sfr */
|
||||||
|
// Timer 0 value
|
||||||
|
__sfr16 __at(0x8c8a) T0_U16;
|
||||||
|
|||||||
+2
-4
@@ -119,8 +119,7 @@ __xdata uint8_t sfp_options[2];
|
|||||||
void isr_timer0(void) __interrupt(1)
|
void isr_timer0(void) __interrupt(1)
|
||||||
{
|
{
|
||||||
TR0 = 0; // Stop timer 0
|
TR0 = 0; // Stop timer 0
|
||||||
TH0 = SYSTICK_TIMER0_VALUE >> 8;
|
T0_U16 = SYSTICK_TIMER0_VALUE;
|
||||||
TL0 = SYSTICK_TIMER0_VALUE % 0xff;
|
|
||||||
TR0 = 1; // Re-start timer 0
|
TR0 = 1; // Re-start timer 0
|
||||||
|
|
||||||
ticks++;
|
ticks++;
|
||||||
@@ -295,8 +294,7 @@ void setup_timer0(void)
|
|||||||
/* The TH0 registers contain the high/low byte that we load into Timer0 when T0
|
/* The TH0 registers contain the high/low byte that we load into Timer0 when T0
|
||||||
* overflows to 0x10000
|
* overflows to 0x10000
|
||||||
*/
|
*/
|
||||||
TH0 = SYSTICK_TIMER0_VALUE >> 8;
|
T0_U16 = SYSTICK_TIMER0_VALUE;
|
||||||
TL0 = SYSTICK_TIMER0_VALUE % 0xff;
|
|
||||||
|
|
||||||
CKCON &= 0xc7;
|
CKCON &= 0xc7;
|
||||||
TCON = 0x10; // Start timer 0
|
TCON = 0x10; // Start timer 0
|
||||||
|
|||||||
Reference in New Issue
Block a user