Read-Only Author Mike Snyder Posted 9-Jan-2009 17:54 GMT Toolset C51 |  RTX51 Tiny & "Timer 1" quandary Mike Snyder Basics: When I attempt to enable Timer 1, RTX51 Tiny no longer will task swap. Details: - RTX51 Tiny running in Round-Robin Mode utilizes Timer 0 - Attempting to implement use of UART0 utilize Timer 1 as baud-rate generator as soon as Timer 1 is enabled, RTX no longer executes normal task swapping
Timer 1 initialization:
// Turn Timer 1 OFF
// --------------------
TR1=0;
// Disable pertinent interrupts
// --------------------
ET1=0; // DISABLE_TIMER_1
ES0=0; // DISABLE_SERIAL_0_INT;
// Define timer 1 mode
// --------------------
TMOD = ( 0x20 | (TMOD & 0x0F) ); // retain definition of Timer 0
// then define Timer 1
// .7: Gate=0b: T/C enabled when TR1=1
// .6: C/T_=0b: timer clkd by internal clk
// .[5:4]: Mode=10b: 8-bit auto-reload
// timer for baud generation.
// .[3-0]: Timer 0 defs
// Configure Timer 1 for baud rate generation:
// -------------------------------------------
// Crystal Frequency: 36.864 MHz
// Timer 1: Mode 2, SMOD=0
// TH1 = 0xEC delivers 4800 Baud with 0% deviation
TH1 =
TL1 = 0xEC; // Timer 1 reload values
PCON &= 0x3F; // PCON.[7:6] = SMOD0:SMOD1 = 0
// No baudrate doubling for UART0 or UART1
// turn serial port on
// --------------------
// Port 0:
SCON0 = 0xE0; // 1110 0000: mode 3: asynch, 11 bits, 1 stop,
// 1 start, (Even) Parity
// SCON0.7: SM0 1: (mode 3: asynch, 11 bits,
// SCON0.6: SM1 1: timer 1 or 2 baud rate equation)
// SCON0.5: SM2 1: RI active when 9th bit = 1
// SCON0.4: REN_0 0: UART reception disabled (for now)
// SCON0.3: TB8_0 0: 9th transmission bit
// SCON0.2: RB8_0 0: 9th data bit that was received
// SCON0.1: TI_0 0: Transmit Interrupt flag.
// SCON0.0: RI_0 0: Receive Interrupt flag.
// turn individual interrupts on
// --------------------
ET1=1; // ENABLE_TIMER_1_INT
ES0=1; // ENABLE_SERIAL_0_INT
// Turn Timer 1 ON
// --------------------
ET1=1; // ENABLE_TIMER_1
Results: After the ET1=1 is executed, the 2nd task of a total of 2 tasks never goes READY and the system stays in the boot task. I can't detect any where in this timer initialization code that could impact the RTX environment.
Can you detect something that is obvious that I'm overlooking? |