Puts out a counter now
This commit is contained in:
		
							
								
								
									
										21
									
								
								flash.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								flash.c
									
									
									
									
									
								
							@ -2,16 +2,21 @@
 | 
				
			|||||||
#include <8052.h>
 | 
					#include <8052.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef FLASH_PIN 
 | 
					#ifndef FLASH_PIN 
 | 
				
			||||||
#define FLASH_PIN _P1_0
 | 
					#define FLASH_PIN _P2_0
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef IRQFREQ
 | 
					#ifndef IRQFREQ
 | 
				
			||||||
#define IRQFREQ 1000L
 | 
					#define IRQFREQ 1000L
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef T0_BITS
 | 
				
			||||||
 | 
					#define T0_BITS 13
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define FOSC (SYSCLK*1000L)
 | 
					#define FOSC (SYSCLK*1000L)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define T0_1MS	(65536L-FOSC/12L/IRQFREQ)
 | 
					#define T0_1MS	((65536)-FOSC/12L/IRQFREQ)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define TCT IRQFREQ/2-1
 | 
					#define TCT IRQFREQ/2-1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -19,9 +24,13 @@ unsigned char ctr_l =  TCT&0xFF;
 | 
				
			|||||||
unsigned char ctr_h = (TCT>>8)&0xff;
 | 
					unsigned char ctr_h = (TCT>>8)&0xff;
 | 
				
			||||||
unsigned char ctr_w = (TCT>>16)&0xff;
 | 
					unsigned char ctr_w = (TCT>>16)&0xff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					unsigned char counter = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void handler() __interrupt 1 
 | 
					void handler() __interrupt 1 
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	EA=0;
 | 
						EA=0;
 | 
				
			||||||
 | 
						TL0 = (T0_1MS) & 0xFF; 	// Initial timer value
 | 
				
			||||||
 | 
					    	TH0 = T0_1MS>>8;	// Initial timer value
 | 
				
			||||||
	__asm
 | 
						__asm
 | 
				
			||||||
	mov a, #0xff
 | 
						mov a, #0xff
 | 
				
			||||||
	dec _ctr_l
 | 
						dec _ctr_l
 | 
				
			||||||
@ -31,9 +40,12 @@ void handler() __interrupt 1
 | 
				
			|||||||
	dec _ctr_w
 | 
						dec _ctr_w
 | 
				
			||||||
	cjne a,_ctr_w, 00001$
 | 
						cjne a,_ctr_w, 00001$
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cpl  FLASH_PIN
 | 
						; cpl  FLASH_PIN
 | 
				
			||||||
	__endasm;
 | 
						__endasm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						counter ++;
 | 
				
			||||||
 | 
						P2 = counter ^0xff;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	ctr_l =  TCT&0xFF;
 | 
						ctr_l =  TCT&0xFF;
 | 
				
			||||||
	ctr_h = (TCT>>8)&0xff;
 | 
						ctr_h = (TCT>>8)&0xff;
 | 
				
			||||||
	ctr_w = (TCT>>16)&0xff;
 | 
						ctr_w = (TCT>>16)&0xff;
 | 
				
			||||||
@ -47,12 +59,11 @@ void handler() __interrupt 1
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void main()
 | 
					void main()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	P1=TMOD;
 | 
						P1=TMOD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	EA=0;
 | 
						EA=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TMOD =0; 
 | 
						TMOD =1; 
 | 
				
			||||||
	P1=TMOD;
 | 
						P1=TMOD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TL0 = (T0_1MS) & 0xFF; 	// Initial timer value
 | 
						TL0 = (T0_1MS) & 0xFF; 	// Initial timer value
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user