Initial commit
This commit is contained in:
		
							
								
								
									
										5
									
								
								f.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								f.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
SYSCLK=36000
 | 
			
		||||
 | 
			
		||||
sdcc -mmcs51 -DSYSCLK=${SYSCLK} flash.c
 | 
			
		||||
stcgal -t ${SYSCLK} flash.ihx
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										67
									
								
								flash.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								flash.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,67 @@
 | 
			
		||||
 | 
			
		||||
#include <8052.h>
 | 
			
		||||
 | 
			
		||||
#ifndef FLASH_PIN 
 | 
			
		||||
#define FLASH_PIN P2_0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef IRQFREQ
 | 
			
		||||
#define IRQFREQ 1000L
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define FOSC (SYSCLK*1000L)
 | 
			
		||||
 | 
			
		||||
#define T0_1MS	(65536L-FOSC/12L/IRQFREQ)
 | 
			
		||||
 | 
			
		||||
#define TCT IRQFREQ/2-1
 | 
			
		||||
 | 
			
		||||
unsigned char ctr_l =  TCT&0xFF;
 | 
			
		||||
unsigned char ctr_h = (TCT>>8)&0xff;
 | 
			
		||||
unsigned char ctr_w = (TCT>>16)&0xff;
 | 
			
		||||
 | 
			
		||||
void handler() __interrupt 1 
 | 
			
		||||
{
 | 
			
		||||
	EA=0;
 | 
			
		||||
	__asm
 | 
			
		||||
	mov a, #0xff
 | 
			
		||||
	dec _ctr_l
 | 
			
		||||
	cjne a,_ctr_l, 00001$
 | 
			
		||||
	dec _ctr_h
 | 
			
		||||
	cjne a,_ctr_h, 00001$
 | 
			
		||||
	dec _ctr_w
 | 
			
		||||
	cjne a,_ctr_w, 00001$
 | 
			
		||||
 | 
			
		||||
	cpl  _P2_0
 | 
			
		||||
	__endasm;
 | 
			
		||||
	
 | 
			
		||||
	ctr_l =  TCT&0xFF;
 | 
			
		||||
	ctr_h = (TCT>>8)&0xff;
 | 
			
		||||
	ctr_w = (TCT>>16)&0xff;
 | 
			
		||||
 | 
			
		||||
	__asm
 | 
			
		||||
	00001$:
 | 
			
		||||
	__endasm;
 | 
			
		||||
	EA=1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void main()
 | 
			
		||||
{
 | 
			
		||||
	
 | 
			
		||||
	P1=TMOD;
 | 
			
		||||
 | 
			
		||||
	EA=0;
 | 
			
		||||
 | 
			
		||||
	TMOD =0; 
 | 
			
		||||
	P1=TMOD;
 | 
			
		||||
 | 
			
		||||
	TL0 = (T0_1MS) & 0xFF; 	// Initial timer value
 | 
			
		||||
    	TH0 = T0_1MS>>8;	// Initial timer value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	TR0 = 1;		// Timer0 start run
 | 
			
		||||
	ET0 = 1;		// Enable timer0 interrupt
 | 
			
		||||
	EA=1;
 | 
			
		||||
 | 
			
		||||
	while(1);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user