Re: Does TINI OS use internally Timer Interrupts?
Peter Wein <[email protected]> Thu, 03 Jun 2004 16:54:19 +0200
| Newsgroups | gmane.comp.hardware.microcontrollers.tini |
|---|---|
| Message-ID | <[email protected]> |
Hello Bryan, you have mentioned below, that I can use TIMER 1 or TIMER 3, if I do not use Serial 1 or Serial 3.. Two questions: 1.) TIMER 1 is not used by Serial0IRqHandler, according to SDCC C- Compiler, which rejected to write there?? 2.) Have you got a code snippet, how to program and initialize for example TIMER 3? At the moment, I could not get working right the below standing example! It should toggle my LED every 0.811 ms according to my figurations based on a machine cycle of 33.8ns. It would be really nice because I am now working on problem for one week, and maybe I have overseen some architectural things. My example is not working with: sdcc -mds400 --model-flat24 --stack-10bit -Wl-r --xram-loc 0x4A0000 --code-loc 0x490000 meinblinki.c then javakit -> DS80C400 Silicon Software - Copyright (C) 2002 Maxim Integrated Products Detailed product information available at http://www.maxim-ic.com Welcome to the TINI DS80C400 Auto Boot Loader 1.0.1 > Loading file: C:\JavaTiniProjects\test\interrupt\a8.hex. Please wait... (ESC to abort.) Loading at bank number 49 Load complete. >B49 >G It only toggles one time but never enters the timer3_isr()! My last question is: if I program it parallel to TINIOS, does it make a difference that according to the sdcc manual, the interrupt vector time table is also shifted to Bank 49??? I mean will that affect the work of the TINI OS in the end, because in the end my simple ISR should be replaced by something running parallel and controlled from TINI JRE! kind regards Peter -- Power Electronics Group Dept. Electrical and Electronic Engineering University of Stellenbosch Mobile. +27 84 816 3795 Tel. +27 21 808 3220 Fax. +27 21 808 3220 mailto:peterw-/[email protected] ---------------------------------------------------------------------------------------------------------------------------------------------------------- //here begins meinblinki.c #include <ds80c400.h> // Because I have to made some changes (registers T3CM and TH3 and TL3 needs to be added) to the origninal SDCC file for DS80C390 I added this include file //at the bottom of this short file! #include <ds400rom.h> #include <stdio.h> #include <tinibios.h> xdata unsigned char T3CM_OLD; xdata unsigned char TH3_OLD; bit EA_OLD, ET3_OLD; volatile xdata long count; const xdata long rate = 2000000; int enableIR(void) { EA_OLD = EA; // save old register states ET3_OLD = ET3; T3CM_OLD = T3CM; TH3_OLD = TH3; // end saving count = 0; //initialize timer counter ET3=1; TH3 = 0xff; //load TH3 with $ff EA = 1; //enable Interrupt, though not already enabled T3CM = 0x42; // Timer 3 in 8-Bit auto reload, internal clock divide by 12, and enable TIMER3 (TR3=1)! P5 ^= 0x04; // Toggle P5.2 return 1; } void timer3_isr(void) interrupt 9 using 1 { count++; if(count==rate){ // 2e6 x 12 x 33.8ns = 811.ms -> every 0.8s it should toggle! P5 ^= 0x04; count = 0; } } int disableIR(void) { EA = EA_OLD; ET3 = ET3_OLD; T3CM = T3CM_OLD; TH3= TH3_OLD; T3CM = 0x00; P5^=0x04; return 1; } void main(void) { long d; int i=0; i=enableIR(); for(d=0;d<=20000000;d++) /* wait loop for 30s<45s<1min dont know exactly _asm nop; nop; nop; _endasm; i=disableIR(); // after xx seconds recover state, disable timer3_isr } //here ends meinblinki.c --------------------------------------------------------------------------------------------------------------------------------------------------------- // here begins the changed DS80C400.h formerly Sdccs Ds80c390.h! /*------------------------------------------------------------------------- Register Declarations for the DALLAS DS80C400 Processor far from complete, e.g. no CAN Written By - Johan Knol, [email protected] This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ #ifndef DS80C390_H #define DS80C390_H sfr at 0x80 P4; // ce3..ce0, a19..a16 sfr at 0x81 SP; // stack pointer sfr at 0x82 DPL; // data pointer 0 lsb sfr at 0x83 DPH; // data pointer 0 msb sfr at 0x84 DPL1; // data pointer 1 lsb sfr at 0x85 DPH1; // data pointer 1 msb sfr at 0x86 DPS; // data pointer select sfr at 0x87 PCON; // power control sfr at 0x88 TCON; // timer/counter control sbit at 0x88 IT0; sbit at 0x89 IE0; sbit at 0x8a IT1; sbit at 0x8b IE1; sbit at 0x8c TR0; sbit at 0x8d TF0; sbit at 0x8e TR1; sbit at 0x8f TF1; sfr at 0x89 TMOD; // timer mode control sfr at 0x8a TL0; // timer 0 lsb sfr at 0x8b TL1; // timer 1 msb sfr at 0x8c TH0; // timer 0 msb sfr at 0x8d TH1; // timer 1 msb sfr at 0x8e CKCON; // clock control sfr at 0x90 P1; sbit at 0x90 T2; sbit at 0x91 T2EX; sbit at 0x92 RXD1; sbit at 0x93 TXD1; sbit at 0x94 INT2; sbit at 0x95 INT3; sbit at 0x96 INT4; sbit at 0x97 INT5; sfr at 0x91 EXIF; // external interrupt flag sfr at 0x92 P4CNT; sfr at 0x93 DPX; // extended datapointer 0 sfr at 0x95 DPX1; // extended datapointer 1 sfr at 0x98 SCON0; // serial 0 control sbit at 0x98 RI_0; sbit at 0x99 TI_0; sbit at 0x9a RB8_0; sbit at 0x9b TB8_0; sbit at 0x9c REN_0; sbit at 0x9d SM2_0; sbit at 0x9e SM1_0; sbit at 0x9f SM0_0; sbit at 0x9f FE_0; // depending on SMOD0 sfr at 0x99 SBUF0; // serial 0 data buffer sfr at 0x9b ESP; // extended stack pointer sfr at 0x9c AP; // address page sfr at 0x9d ACON; // address control sfr at 0xa0 P2; // never mind the sbits sfr at 0xa1 P5; sfr at 0xa2 P5CNT; sfr at 0xa8 IE; // interrupt enable sbit at 0xa8 EX0; sbit at 0xa9 ET0; sbit at 0xaa EX1; sbit at 0xab ET1; sbit at 0xac ES0; sbit at 0xad ET2; sbit at 0xae ES1; sbit at 0xaf EA; sfr at 0xb0 P3; sbit at 0xb0 RXD0; sbit at 0xb1 TXD0; sbit at 0xb2 INT0; sbit at 0xb3 INT1; sbit at 0xb4 T0; sbit at 0xb5 T1; sbit at 0xb6 WR; sbit at 0xb7 RD; sfr at 0xb8 IP; // interupt priority sbit at 0xb8 PX0; // external 0 sbit at 0xb9 PT0; // timer 0 sbit at 0xba PX1; // external 1 sbit at 0xbb PT1; // timer 1 sbit at 0xbc PS0; // serial port 0 sbit at 0xbd PT2; // timer 2 sbit at 0xbe PS1; // serial port 1 sfr at 0xc0 SCON1; // serial 1 control sbit at 0xc0 RI_1; sbit at 0xc1 TI_1; sbit at 0xc2 RB8_1; sbit at 0xc3 TB8_1; sbit at 0xc4 REN_1; sbit at 0xc5 SM2_1; sbit at 0xc6 SM1_1; sbit at 0xc7 SM0_1; sbit at 0xc7 FE_1; // depending on SMOD0 sfr at 0xc1 SBUF1; // serial 1 data buffer sfr at 0xc4 PMR; // power managment sfr at 0xc6 MCON; // memory control register sfr at 0xc7 TA; // timed access register sfr at 0xc8 T2CON; // timer 2 control sbit at 0xc8 CP_RL; // capture/reload sbit at 0xc9 C_T; // count/timer sbit at 0xca TR2; // stop/run sbit at 0xcb EXEN2; sbit at 0xcc TCLK; sbit at 0xcd RCLK; sbit at 0xce EXF2; sbit at 0xcf TF2; // overflow flag sfr at 0xc9 T2MOD; // timer 2 mode sfr at 0xca RCAP2L; // timer 2 capture/reload sfr at 0xca RTL2; // depends on CP_RL sfr at 0xcb RCAP2H; sfr at 0xcb RTH2; sfr at 0xcc TL2; // timer 2 lsb sfr at 0xcd TH2; // timer 2 msb sfr at 0xd0 PSW; // program status word (byte actually) sbit at 0xd0 P; // parity sbit at 0xd1 F1; // user flag 1 sbit at 0xd2 OV; // overflow flag sbit at 0xd3 RS0; // register select l sbit at 0xd4 RS1; // register select h sbit at 0xd5 F0; // user flag 0 sbit at 0xd6 AC; // auxiliary carry flag sbit at 0xd7 CY; // carry flag sfr at 0xd1 MCNT0; // arithmetic accellerator sfr at 0xd2 MCNT1; sfr at 0xd3 MA; sfr at 0xd4 MB; sfr at 0xd5 MC; sfr at 0xd8 WDCON; // watch dog sbit at 0xd8 RWT; sbit at 0xd9 EWT; sbit at 0xda WDRF; sbit at 0xdb WDIF; sbit at 0xdc PFI; sbit at 0xdd EPFI; sbit at 0xde POR; sbit at 0xdf SMOD_1; sfr at 0xe0 ACC; // accumulator sfr at 0xe8 EIE; // extended interrupt enable sbit at 0xe8 EX2; sbit at 0xe9 ET3; sbit at 0xea ES2; sbit at 0xeb EWPI; sbit at 0xec EWDI; sbit at 0xed EAIE; sbit at 0xee C0IE; sbit at 0xef EPMIE; sfr at 0xea MXAX; // extended address register sfr at 0xf0 B; // aux accumulator sfr at 0xf8 EIP; // extended interrupt priority sbit at 0xf8 PX2; sbit at 0xf9 PX3; sbit at 0xfa PX4; sbit at 0xfb PX5; sbit at 0xfc PWDI; sbit at 0xfd C1IP; sbit at 0xfe C0IP; sbit at 0xff CANBIP; sfr at 0xfb TL3; // Timer 3 LSB sfr at 0xfc TH3; // Timer 3 MSB sfr at 0xfd T3CM; // Timer 3 Control/Mode Register #endif /* DS80C400_H */ //here it ends! -------------------------------------------------------------------------------------------------------------------------------------------------- Bryan Armstrong wrote: > Peter Wein wrote: > >> Is it possible: to go native and program an Timer Interrupt (each >> 10ms)in a method of a tlib. Also the termination of the timer >> interrrupt). Then you write a code and put it in a memory, where >> TINIOS has got no access. ISR jumps to that disable interrupts, >> measures ADCs via Max1080 SPI and returns to the next process. > > > Yes. This would also have to be completely written in assembler. No > Java. > >> If this makes sense, this must work, if you be careful and save the >> system state before you jump to the ISR, unless TINI OS is using >> TImer Interrupts for its own purposes. So does it? > > > You can use timer 3 if you are not using serial 2 (SBUF2) > You can use timer 1 if you are not using serial 1 (SBUF1) > > > _______________________________________________ TINI mailing list TINI-6tN4nzCoH/[email protected] To UNSUBSCRIBE, edit your profile, or see list archives: http://lists.dalsemi.com/mailman/listinfo/tini