Mình đang code cho led ma trận nếu khai báo mảng ít thì chạy bình thường nhưng khai báo mã led nhiều quá tầm > 80byte thì bị báo lổi không đủ RAM cho các biến. mình khai báo kiểu const unsigned char thì không bị lổi nửa nhưng code lại không chạy. bạn nào biết khai báo nhiều byte trong mảng mà chạy vẩn ok chỉ dùm mình với. thank nhiều
link: Mtrix
Code:
#include <16F887.h> #FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT,NOLVP, NOCPD, NOWRT #use delay(clock=20000000) #use fast_io(A) #use fast_io(B) #use fast_io(C) #use fast_io(D) #use fast_io(E) #byte PORTA=0x05 #byte PORTB=0x06 #byte PORTC=0x07 #byte PORTD=0x08 #byte PORTE=0x09 #byte STATUS=0X03 #byte ANSEL=0x188 #byte ANSELH=0x189 signed char n,k,l,diachi,decode,machu; unsigned char h,quethang,sohang,socot,tocdo,sieutoc; //========================================================================== byte mung_tan_gia[74]={ 0x00,0xFE,0xFE,0x40,0x30,0x0C,0x30,0x40,0xFE,0xFE,0x00,0x3C,0xBE,0x42,0x02,0x3E,0x3C,0x40,0x3E,0x3E, 0x20,0x20,0x1E,0x0E,0x00,0x39,0x25,0x25,0x1F,0x00,0x00,0x80,0x80,0xFE,0xFE,0x80,0x80,0x0C,0x52,0x92, 0x5E,0x02,0x00,0x3E,0x3E,0x20,0x20,0x3E,0x1E,0x00,0x00,0x00,0x7C,0xFE,0x82,0x82,0x96,0xDC,0x10,0x00, 0x5E,0x00,0x0C,0x12,0x12,0x12,0x1E,0x02,0x00,0x00,0x00,0x00,0x00,0x00, }; /* mung_tan_gia []={ 0x00,0x3C,0x7E,0xC3,0x81,0x81,0x81,0x42,0x00,0xFF,0x08,0x10,0x10,0x18,0x0F,0x07,0x00,0x1E,0x1F,0x01, 0x41,0x9F,0x1E,0x00,0x0E,0x1F,0x11,0x11,0x11,0x00,0x00,0x00,0x00,0xFF,0x7F,0x30,0x18,0x0C,0x18,0x30, 0x7F,0xFF,0x00,0x1E,0x9F,0x41,0x01,0x1F,0x1E,0x20,0x00,0x1F,0x08,0x10,0x10,0x10,0x0F,0x07,0x00,0x0E, 0x1F,0x11,0x15,0x15,0x16,0x00,0x00,0x00,0xFF,0xFF,0x60,0x30,0x18,0x0C,0x06,0xFF,0xFF,0x00,0x0E,0x9F, 0x51,0x51,0x51,0x9F,0x00,0x0F,0x1F,0x18,0x08,0x07,0x08,0x18,0x1F,0x0F,0x00,0x00,0x00,0x00,0xFF,0x7F, 0x30,0x18,0x0C,0x18,0x30,0x7F,0xFF,0x00,0x0E,0x1F,0x11,0x51,0x9F,0x0E,0x10,0x00,0x5F,0x00,0x00,0x00 }; //120 */ //------------------------------------------------------------------------------ void display_rl() { diachi=-49; k=0; sieutoc=1; for(socot=122;socot>0;socot--) { for(tocdo=sieutoc;tocdo>0;tocdo--) { quethang=0x00; h=0x80; for(sohang=8;sohang>0;sohang--) { output_low(PIN_B5); for(machu=diachi;machu<k;machu++) { output_low(PIN_B2); decode=mung_tan_gia[machu]; if(machu<0) decode=0; if(machu>73) decode=0; if((decode&h)==h) output_high(PIN_B3); else output_low(PIN_B3); output_high(PIN_B2); } output_high(PIN_B5); PORTD=quethang; delay_us(1000); PORTD=8; quethang++; h>>=1; } } k++; diachi++; if(k==46) sieutoc=10; } } void main(void) { STATUS=0x00; //chon bank 0 96byte set_tris_D(0); set_tris_B(0); set_tris_C(0); ANSEL=ANSELH=0; while(true) { display_rl(); // display_lr(); } }
Comment