a anh ơi~! em viết chạy ổn rồi ne!
Code:
#include "E:\ccs c\chuong_trinh_ccsc\banh_kem_duc_thanh\chuong_trinh.h"
#int_RB
RB_isr()
{
int8 y;
disable_interrupts(INT_RB);
disable_interrupts(GLOBAL);
if ( input(PIN_B6) ) //tang gia tri trong o nho
{
y = read_eeprom(0x00);
if(y<244)
{
y = y + 10;
write_eeprom (0x00,y);
}
}
if ( input(PIN_B7) ) //giam gia tri trong o nho
{
y = read_eeprom(0x00);
if(y>10)
{
y = y - 10;
write_eeprom (0x00,y);
}
}
delay_ms(50);
enable_interrupts(GLOBAL);
enable_interrupts(INT_RB);
}
//===========CAC CHUONG TRINH CON==============
void tao_tre(int8 x);
//============================================
void main()
{
output_B(0x00);
output_A(0x00);
enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);
while(1)
{
output_high(pin_B0);
tao_tre(1);
output_low(pin_B0);
tao_tre(1);
output_high(pin_B1);
tao_tre(1);
output_low(pin_B1);
tao_tre(1);
output_high(pin_B2);
tao_tre(1);
output_low(pin_B2);
tao_tre(1);
output_high(pin_B3);
tao_tre(1);
output_low(pin_B3);
tao_tre(1);
output_low(pin_B0);
output_low(pin_B1);
output_low(pin_B2);
output_low(pin_B3);
tao_tre(1);
output_high(pin_B0);
output_high(pin_B1);
output_high(pin_B2);
output_high(pin_B3);
tao_tre(1);
output_low(pin_B0);
output_low(pin_B1);
output_low(pin_B2);
output_low(pin_B3);
tao_tre(1);
}
}
//============================================
void tao_tre(int8 x)
{
int8 z,i;
z = x + read_eeprom (0x00);
delay_ms(100);
for(i=0;i<z;++i)
delay_ms(2);
}
//===========================================