Beispiel #1
0
/***************************************************************************//**
 * @brief 	Reads the values from a timer in EEPROM and copies them into the RAM variable of the Timer selected
 * @param   Address            This is the address 
 * @param   Timer_HighScore    This is a pointer to the timer in RAM
 * @return 	None.
 * @date	  14.11.2013 
*******************************************************************************/
void Read_Timer_from_EEPROM(unsigned char Address, struct TimerStruct * Timer_HighScore)
{
  Timer_HighScore->Dmin = EEPROM_Read(Address);
  Timer_HighScore->Umin = EEPROM_Read(Address + 1);
  Timer_HighScore->Dsec = EEPROM_Read(Address + 2);
  Timer_HighScore->Usec = EEPROM_Read(Address + 3);    
}
Beispiel #2
0
    void Read_MAC_Address(uint8_t *myAddress)
{
    uint8_t i;
    
    if( MY_ADDRESS_LENGTH > 6 )
    {
        for(i = 0; i < 3; i++)
        {
            EEPROM_Read(&(myAddress[MY_ADDRESS_LENGTH-1-i]), EEPROM_MAC_ADDR+i, 1);
        }

        if( MY_ADDRESS_LENGTH > 7 )
        {
            myAddress[4] = 0xFF;

        }
        myAddress[3] = 0xFE;

        for(i = 0; i < 3; i++)
        {
            EEPROM_Read(&(myAddress[2-i]), EEPROM_MAC_ADDR+3+i, 1);
        }
    }
    else
    {
        for(i = 0; i < MY_ADDRESS_LENGTH; i++)
        {
            EEPROM_Read(&(myAddress[i]), EEPROM_MAC_ADDR+5-i, 1);
        }
    }
}
Beispiel #3
0
static
#endif // EEPROM_INCLUDE_BYTE_FUNCS
void EEPROM_WriteWearLeveledByte(const uint16_t param, const uint8_t data) {
  uint16_t address = EEPROM_FindCurrentAddress(param);

  // Only perform the write if the new value is different from what's currently stored
  if (EEPROM_Read(address) == data)
    return;

  // Store the old status value
  uint8_t oldStatusValue = EEPROM_Read(address + EE_PARAM_BUFFER_SIZE);

  // Move pointer to the next element in the buffer, wrapping around if necessary
  if (++address == param + EE_PARAM_BUFFER_SIZE)
    address = param;

  // If self-programming is used in the application, insert code here
  // to wait for any self-programming operations to finish before
  // writing to the EEPROM.

  // Update the param buffer in the EEPROM
  EEPROM_Write(address, data);

  // Update the status buffer in the EEPROM
  EEPROM_Write(address + EE_PARAM_BUFFER_SIZE, oldStatusValue + 1);
}
Beispiel #4
0
/** function loads calibration table from EEPROM, validate it and if OK uses it */
static void touch_LoadCalibration(void)
{
  I2C_Init_TypeDef i2cInit = I2C_INIT_DEFAULT;
  uint32_t         temp, checksum;
  int              count;
  MATRIX           new_matrix;
  /* Initialize I2C driver, using standard rate. Devices on DK itself */
  /* supports fast mode, but in case some slower devices are added on */
  /* prototype board, we use standard mode. */
  I2CDRV_Init(&i2cInit);
  count  = EEPROM_Read(I2C0, EEPROM_DVK_ADDR, CALIBRATION_EEPROM_OFFSET, (uint8_t*) &temp, sizeof(temp));
  count += EEPROM_Read(I2C0, EEPROM_DVK_ADDR, CALIBRATION_EEPROM_OFFSET + 4, (uint8_t*) &new_matrix, sizeof(new_matrix));
  if (count == sizeof(new_matrix) + 4)
  {
    if (temp == CALIBRATION_MAGIC_NUMBER)
    {
      checksum = touch_CountChecksum(temp, (uint32_t*) &new_matrix, sizeof(new_matrix) / 4);
      count    = EEPROM_Read(I2C0, EEPROM_DVK_ADDR, CALIBRATION_EEPROM_OFFSET + 4 + sizeof(new_matrix), (uint8_t*) &temp, sizeof(temp));
      if (temp == checksum)
      {                                      /* looks like calibration table is valid */
        ADC_IntDisable(ADC0, ADC_IF_SINGLE); /* we need to disable ADC interrupt to avoid current_pos structure update for a while */
        memcpy(&calibrationMatrix, &new_matrix, sizeof(calibrationMatrix));
        ADC_IntEnable(ADC0, ADC_IF_SINGLE);
      }
    }
  }
}
Beispiel #5
0
//TODO: Can I combine these EEPROM bits to a single byte?
void App_InitializeFromEEPROM(void)
{
	uint8_t StatusReg;


	//Read status of the timer and set up the device
	if( EEPROM_Read(EEPROM_ADDRESS_TIMER_STATUS, &StatusReg, 1 ) != 0)
	{
		App_Die(8);
	}


	if((StatusReg == TIMER_STATUS_ON) && (App_GetStatus() != APP_STATUS_OSC_STOPPED))
	{
		//Start the timer if it was running when we shut down last, but do not start the timer if the time is invalid
		//TODO: What should I do if the timer status is override?
		StartTimer();
	}


	//Read status of the OLED
	if( EEPROM_Read(EEPROM_ADDRESS_DISPLAY_STATUS, &StatusReg, 1 ) != 0)
	{
		App_Die(8);
	}

	OLED_DisplayRotation(StatusReg & OLED_STATUS_ORENTATION_MASK);





	return;
}
Beispiel #6
0
/* initialize for touch & calibration */
int touch_calibration_init(void)
{
    rt_uint8_t magic = 0;
    calculate_data_t data;
    struct rtgui_calibration_ops *ops;

    ops = calibration_get_ops();

    /* initialization the eeprom  on chip  */
    EEPROM_Init();
    /* initialization the touch driver */
    rtgui_touch_hw_init("spi10");
    /* set callback to save calibration data */
    calibration_set_after(calibration_data_save);
    /* initialization rtgui tonch server */
    rtgui_touch_init(ops);
    /* restore calibration data */
    EEPROM_Read(0, CALIBRATION_DATA_PAGE, &magic, MODE_8_BIT, 1);
    if (CALIBRATION_DATA_MAGIC != magic)
    {
        rt_kprintf("touch is not calibration,now calibration it please.\n");
        calibration_init(RT_NULL);
    }
    else
    {
        EEPROM_Read(CALIBRATION_DATA_OFFSET, CALIBRATION_DATA_PAGE, &data, MODE_8_BIT, sizeof(calculate_data_t));
        calibration_set_data(&data);
    }
    /* power down the EEPROM */
    EEPROM_PowerDown(ENABLE);
    return 0;
}
void Reflow_LoadCustomProfiles(void) {
	EEPROM_Read((uint8_t*)ee1.temperatures, 2, 96);
	ByteswapTempProfile(ee1.temperatures);

	EEPROM_Read((uint8_t*)ee2.temperatures, 128 + 2, 96);
	ByteswapTempProfile(ee2.temperatures);
}
void leEEPROM(){
   unsigned short eeprom_adress;          //Variável auxiliar local
   eeprom_adress = EEPROM_Read(0x00);     //Lemos o endereço 0h da EEPROM e armazemos o valor em eeprom_adress

   if(eeprom_adress == 0xFF) {            //Testando eeprom_adress, EEPROM limpa? Sim...
      EEPROM_Write(0x00, INIT_ADRESS);    //Força escrita do valor 1 no endereço 0x00;
      delay_ms(10);                       //Tempo para escrita
   } else if(eeprom_adress == INIT_ADRESS)
      cont = EEPROM_Read(MAX_ADRESS);
   else
      cont = EEPROM_Read(eeprom_adress - 0x01);
}
/*
* Entry point
*/
void main() {
  // Variables
  char speedBuf[5] = {0,0,0,0,0};
  char totalBuf[] = {0,0,0,0,0,0,0,0,0,0};
  char empty[] = "                ";
  union eeprom_int totalKm;
  int kph = 1;

  // Initialization
  initialize();
  
  // 0x10 = first byte of the actual int value
  // 0x11 = second byte of the actual int value
  totalKm.memory[0] = EEPROM_Read(KM_ADDR);
  totalKm.memory[1] = EEPROM_Read(KM_ADDR+1);

  // 0xFF is 8 bit, an uint is 2 byte = 16 bit, so we need 0xFFFF
  if(totalKm.value == 0xFFFF) {
    totalKm.value = 0;
  }
  
  do {
    // Reads the value of the RA2 Analog knob.
    adcInput = ADC_Read(2);

    
    if(shouldUpdateSpeedometer == 1) {
      shouldUpdateSpeedometer = 0;
      // Update speedometer LCD here
      speed(speedBuf, adcInput, &kph);
      Lcd_Out(1,1,empty);
      Lcd_Out(1,1,"km/t: ");
      Lcd_Out(1,7,speedBuf);
    }
    
    if(shouldUpdateTotal) {
      shouldUpdateTotal = 0;
      // Update LCD and save total here
      total(totalBuf, &totalKm.value, kph);
      
      EEPROM_Write(KM_ADDR, totalKm.memory[0]);
      EEPROM_Write(KM_ADDR+1, totalKm.memory[1]);
      Lcd_Out(2,1,empty);
      Lcd_Out(2,1, "Total: ");
      Lcd_Out(2,8, totalBuf);
    }
    
  }while(1);
}
Beispiel #10
0
void Reflow_Init(void) {
//	PID_init(&PID,16,0.1,2,PID_Direction_Direct);
	PID_init(&PID,17,0.11,2,PID_Direction_Direct);
	EEPROM_Read((uint8_t*)ee1.temperatures, 2, 96);
	ByteswapTempProfile(ee1.temperatures);
	EEPROM_Read((uint8_t*)ee2.temperatures, 128+2, 96);
	ByteswapTempProfile(ee2.temperatures);
	intsetpoint = 30;
	PID.mySetpoint = 30.0f; // Default setpoint
	PID_SetOutputLimits(&PID, 0,255+248);
	PID_SetMode(&PID, PID_Mode_Manual);
	PID.myOutput = 248; // Between fan and heat
	PID_SetMode(&PID, PID_Mode_Automatic);
	RTC_Zero();
}
Beispiel #11
0
static uint16_t EEPROM_FindCurrentAddress(const uint16_t param) {
  uint16_t EeBufPtr = param + EE_PARAM_BUFFER_SIZE; // point to the status buffer
  uint16_t EeBufEnd = EeBufPtr + EE_STATUS_BUFFER_SIZE; // the first address outside the buffer

  // Identify the last written element of the status buffer
  uint8_t tmp;
  do {
    tmp = EEPROM_Read(EeBufPtr);
    if (++EeBufPtr == EeBufEnd) // avoid comparing out-of-bounds
      break;
  } while (EEPROM_Read(EeBufPtr) == (uint8_t)(tmp + 1));

  // Return the last used element of the param buffer
  return EeBufPtr - (EE_PARAM_BUFFER_SIZE + 1);
}
INT __init rtusb_init(void)
{
	INT res = 0;

#ifdef CE_READ_EEPROM_PROFILE_SUPPORT
	/* Eeprom address on host platform storing profile idx. */
	#define CUST_EEPROM_ADDR_PROFILE_IDX	(0x10104)
	UINT64	eeprom_addr = CUST_EEPROM_ADDR_PROFILE_IDX;
	int 	eeprom_retval = -1;	
	
	eeprom_retval = EEPROM_Read(eeprom_addr, (UINT32) &eeprom_profile_idx, 1);
	if (eeprom_retval == 0) {
		printk("\nEEPROM_Read success\n");
		printk("\n----- EEPROM_Read retval: %d, eeprom value: %d -----\n", eeprom_retval, eeprom_profile_idx);
	} else {
		printk("\nEEPROM_Read fail\n");
	}
#endif /* CE_READ_EEPROM_PROFILE_SUPPORT */

	printk("%s : %s --->\n", __FUNCTION__, RTMP_DRV_NAME);
	res = usb_register(&rtusb_driver);	
#ifdef MODULE_INIT_DELAY_SLEEP
	printk("%s : sleeping for %d ms\n", __FUNCTION__, init_sleep_ms);
	if (init_sleep_ms)
		msleep(init_sleep_ms);
#endif /* MODULE_INIT_DELAY_SLEEP */

	printk("Exiting %s\n", __FUNCTION__);
	return res;
}
void main(){
ADCON1 = 0b00001110;             // HABILITA CANAL AN0 E AN1
TRISA.RA0 = 1;
Lcd_Init ();                     // START LCD
Lcd_Cmd(_Lcd_Clear);             // CLEAR LCD
Lcd_Cmd(_LCD_CURSOR_OFF);        // TURN OFF LCD CURSOR
ADC_Init();
while(1){
adc_rd = ADC_Read(0);                        // GET ADC VALUE FROM 1ST CHANNEL
EEPROM_Write(0x08, adc_rd);       //ESCREVE "adc_rd" NA POSICAO 0x08 DA EEPROM
IntToStr(adc_rd, adcprint);                            // CONVERSION TO STRING
Lcd_out(1,1,"COUNTS..: ");
Lcd_Out_Cp(adcprint);                     // PRINTS ADC STEPS IN LCD FIRST ROW
if (diff != adc_rd){
BarSegmentNum = adc_rd /(1023 / 16);
                                    // CALCULATE NUMBERS OF BAR GRAPH SEGMENTS
Lcd_out(2,1,"                ");    // CLEARS LCD SECOND ROW
for (i = 0; i < BarSegmentNum; i++){
                               // LOOP TO PRINT EACH BAR SEGMENT IN SECOND ROW
CustomChar(2, i+1);}}           // PRINT CUSTOM CHARACTER FOR BARGRAPH SEGMENT
Delay_ms(750);                                        // STABILIZE LCD DISPLAY
diff = adc_rd;
// LCD SHOWS EEPROM VALUE
ADCeer = EEPROM_Read(0x08);                     // LE A POSICAO 0x08 DA EEPROM
ShortToStr (ADCeer, ADCeerSTR);
//Lcd_Cmd(_LCD_CLEAR);                                  // LIMPA A TELA DO LCD
Lcd_Out(2, 1, ADCeerSTR);
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);                                    // LIMPA A TELA DO LCD
}                                                                 // END WHILE
}                                                                  // END MAIN
Beispiel #14
0
void GetEntriesStr(unsigned char *out) {
	unsigned char b[4];
	int n;
	n = EEPROM_Read(0);
	strcpy(out, "Entries: ");
	WordToStr(n, b);
	strcat(out, b);
}
/*******************************************************************************
**函    数: Cube6_ReadEeprom
**功    能: 读取上次保存的面值
**参    数: void
**返    回: 匹配面(1-6)      0xFF   未匹配
*******************************************************************************/
void  Cube6_ReadEeprom(void)
{
    EEPROM_Read(CUBE_EEPROM_START_ADDR, 1, &OldEnsureFace);
    if(OldEnsureFace>6)
    {
        OldEnsureFace = 0;
    }
}
Beispiel #16
0
char CheckIfDeleteMaster()
{
  char i,res=1;
  for(i=0;i<10;i++)
    if(Conn.Data[i]!=EEPROM_Read(i+10))
      {res=0;break;}

  return res;
}
Beispiel #17
0
uint8_t verifyBootLoad(){
	uint16_t BootLoadAddress= getFormatedAddress(CHECK_BOOT_LOAD_ADDR);
	uint32_t buffer=0;
	EEPROM_Read(&BootLoadAddress,&buffer, 4);
	printf("code? = 0x%X\n",buffer);
	if(buffer != BootLoadCode)
		return 0;
	return 1;
}
Beispiel #18
0
void ReadNumberFromEEProm(void)
{
    MobileNumber[0] = EEPROM_Read(0x00);
    MobileNumber[1] = EEPROM_Read(0x01);
    MobileNumber[2] = EEPROM_Read(0x02);
    MobileNumber[3] = EEPROM_Read(0x03);
    MobileNumber[4] = EEPROM_Read(0x04);
    MobileNumber[5] = EEPROM_Read(0x05);
    MobileNumber[6] = EEPROM_Read(0x06);
    MobileNumber[7] = EEPROM_Read(0x07);
    MobileNumber[8] = 0;
}
Beispiel #19
0
short int EEPROM_GetInt(int addr)
{
	volatile int i;
	if (_iseepromenabled )
	{	EEPROM_Read(addr,(unsigned char*)&i,2,FALSE);
	} else
	{	i = EEPROMNULL;
	}
	return i;
}
void EEPROM_Write( u32 Offset, u16 Data )
{
	volatile FLASH_Status FLASHStatus;
	u32 Adr;
	u16 cnt;
	u16 Buffer[512];

	Adr = EEPROM_START_ADDRESS + (Offset<<1);

	if( (Data != EEPROM_Read(Offset)) && (Offset<512) )
	{
		for( cnt=0; cnt<512; cnt++ )
		{
			Buffer[cnt] = EEPROM_Read(cnt);
		}
		Buffer[Offset] = Data;

		FLASH_Unlock();
		/* Clear All pending flags */
		FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);

		if( (Data==0) || (EEPROM_Read(Offset)==0xFFFF) )
		{
			FLASHStatus = FLASH_ProgramHalfWord( Adr, Data );
		}
		else
		{		// Erase
			/* Erase the FLASH pages */
			FLASHStatus = FLASH_ErasePage( EEPROM_START_ADDRESS);

			Adr = EEPROM_START_ADDRESS;

			for( cnt=0; cnt<512; cnt++ )
			{
				if( Buffer[cnt] != 0xFFFF ) FLASHStatus = FLASH_ProgramHalfWord( Adr, Buffer[cnt] );
				Adr += 2;
			}
		}

		FLASH_Lock();
	}
}
Beispiel #21
0
// 获取EEPROM保存变量与报表的格式版本号(长度:4字节)
int GetEEPROMInfoFormatVersion(char* pbVerion, int iLen)
{
    if ( iLen >= VERSION_LEN )
    {
        return EEPROM_Read(VERSION_ADDR, pbVerion, VERSION_LEN);
    }
    else
    {
        return -1;
    }
}
Beispiel #22
0
// 获取Uboot版本信息(长度:128字节)
int GetUbootVersion(char* pbVerion, int iLen)
{
    if ( iLen >= UBOOT_VERSION_LEN )
    {
        return EEPROM_Read(UBOOT_VERSION_ADDR, pbVerion, UBOOT_VERSION_LEN);
    }
    else
    {
        return -1;
    }
}
Beispiel #23
0
//------------------------------------------------------------
void RestoreCalibrate(void)		 //восстановление точек калибровки из EEPROM
{
	unsigned char i=0;
	unsigned long crc=0,true_crc=0;

	for(i=0;i<CHANNEL_NUMBER;i++)
	{
		EEPROM_Read(&channels[i].calibrate.serialize[0],3,ADC_CALIBRATE_ADDR+i*3);
	}

	true_crc= (unsigned long)Calibrate_Get_CRC();//расчет текущей CRC калибровок
	EEPROM_Read(&crc,1,CALIBRATE_DEVICE_CRC_ADDR);//считаем CRC настроек

	if(true_crc!=crc)
	{
		Calibrate_Set_Default();
	}

	return;
}
Beispiel #24
0
void EEPROM_Init( void ) {
#define DUMP_EEPROM
#ifdef DUMP_EEPROM
	uint8_t dumpbuf[256];
	EEPROM_Read(dumpbuf, 0, sizeof(dumpbuf));
	printf("\nEEPROM contents:\n");
	for(int foo=0;foo<sizeof(dumpbuf);foo++) {
		printf(" 0x%02x",dumpbuf[foo]);
	}
#endif
	// No init needed at this point, maybe detect the actual presence some day
}
Beispiel #25
0
// Save settings to EEPROM
void SaveSettings_EEPROM(void) {
	uint32_t *ptr = (uint32_t *)&Settings;
	uint8_t i;
	uint32_t data;

	EEPROM_Unlock();
	for (i = 0; i < sizeof(Settings); i += 4) {
		data = *ptr++;
		if (data != EEPROM_Read(DATA_EEPROM_START_ADDR + i)) EEPROM_Write(DATA_EEPROM_START_ADDR + i,data);
	}
	EEPROM_Lock();
}
bool EEPROM_Test()
{
    uint8_t writeData[EEPROM_TEST_BUFFER_SIZE];
    uint8_t readData[EEPROM_TEST_BUFFER_SIZE];
    uint16_t i;
    
    for(i=0; i<EEPROM_TEST_BUFFER_SIZE; i++){
        writeData[i] = i;
    }
    
    EEPROM_Read(EEPROM_TEST_DATA_ADDR, readData, EEPROM_TEST_BUFFER_SIZE);
    EEPROM_Write(EEPROM_TEST_DATA_ADDR, writeData, EEPROM_TEST_BUFFER_SIZE);
    EEPROM_Read(EEPROM_TEST_DATA_ADDR, readData, EEPROM_TEST_BUFFER_SIZE);
    
    for(i=0; i<EEPROM_TEST_BUFFER_SIZE; i++){
        if(writeData[i] != readData[i]){
            return false;
        }
    }
    
    return true;
}
Beispiel #27
0
void main(void)
{
     char rom_data[7];
     
     //setup UART
     UART1_Init(9600);      //setup UART for 9600bps comm
     UART1_Write_Text("mikroC EEPROM TEST\n");
     
     //write to EEPROM
     EEPROM_Write(0, '1');    //write data
     Delay_ms(20);            //needed to ensure correct write/read
     
     EEPROM_Write(1, '2');    //write data
     Delay_ms(20);            //needed to ensure correct write/read
     
     EEPROM_Write(2, '3');    //write data
     Delay_ms(20);            //needed to ensure correct write/read
     
     //Read from EEPROM
     IntToStr((int)EEPROM_Read(0), rom_data);      //read data
     UART1_Write_Text("EEPROM Data : ");
     UART1_Write_Text(rom_data);
     UART_Write('\n');
     Delay_ms(20);            //needed to ensure correct write/read
     
     IntToStr((int)EEPROM_Read(1), rom_data);      //read data
     UART1_Write_Text("EEPROM Data : ");
     UART1_Write_Text(rom_data);
     UART_Write('\n');
     Delay_ms(20);            //needed to ensure correct write/read
     
     IntToStr((int)EEPROM_Read(2), rom_data);      //read data
     UART1_Write_Text("EEPROM Data : ");
     UART1_Write_Text(rom_data);
     UART_Write('\n');
     Delay_ms(20);            //needed to ensure correct write/read
     
     while(1);
}
Beispiel #28
0
/**
  * @brief  Settings_SaveParam
  * @param  None
  * @retval None
  */
static uint8_t Settings_LoadParam(const SettingsParam_TypeDef* param)
{
	uint8_t CS_ReadByte, CS_ControlByte;
	uint8_t p_data[param->num_bytes + 1];

	/* First read and verify CRC byte */
	EEPROM_Read(p_data, param->start_addr, param->num_bytes);
	EEPROM_Read(&CS_ReadByte, param->start_addr + param->num_bytes, 1);

	/* if CRC is OK copy readed data to param */
	CS_ControlByte = Settings_U8_CS(p_data[0], param->num_bytes);
	if(CS_ReadByte == CS_ControlByte)
	{
		memcpy((uint8_t*)param->u8_data, p_data, param->num_bytes);
		return 0;
	}
	else
	{
		Settings_EraseParam(param);
		return 255;
	}
}
void main() {            // FUNCAO PRINCIPAL: MAIN
ADCON1 = 0x07;           // CONFIGURA ENTRADAS AN COMO E/S DIGITAIS
CMCON = 7;               // DESLIGA COMPARADORES
// CONFIGURACOES E/S E ESTADOS INICIAIS [BINARIO]
   TRISA = 0b00000000;            PORTA = 0b00000000;
   TRISB = 0b00000110;         // PORTB = 0b00000000;
   TRISC = 0b00000000;            PORTC = 0b00000000;
// ESTADOS INICIAIS DOS ACESSORIOS
BUZZER = 1;
// MENSAGEM INICIAL NO LCD
Lcd_Init();                                 // INICIA O LCD
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Cmd(_LCD_CURSOR_OFF);                   // DESLIGA O CURSOR
Lcd_Out(1, 1, msg_2); 
Lcd_Out(2, 1, msg_1);
Delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
while (1) {
if (!INT2) {
BUZZER = 0; Delay_ms(15); BUZZER = 1; Delay_ms(50);
BUZZER = 0; Delay_ms(15); BUZZER = 1;       // SIRENE SOA DUAS VEZES CURTAS
// EEPROM_Write(unsigned short address, unsigned short data);
EEPROM_Write(0x08, 'K');               //ESCREVE "K" NA POSICAO 0x08 DA EEPROM
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1, 1, msg_1);
Lcd_Out(2, 1, msg_3);   
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
} else if (!INT1) {
BUZZER = 0; Delay_ms(15); BUZZER = 1;       // SIRENE SOA UMA VEZ CURTA
// EEPROM_Read(unsigned short address);
INFO = EEPROM_Read(0x08);                   // LE A POSICAO 0x08 DA EEPROM
ShortToStr (INFO, INFO_s);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1, 1, msg_1);
Lcd_Out(2, 1, msg_4);   
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1,1,INFO_s);   
Lcd_Out_Cp(" = DECIMAL");      
Lcd_Cmd(_LCD_SECOND_ROW);
Lcd_Chr_Cp(0+INFO);    
Lcd_Out_Cp(" =  CHARACTER");   
Delay_ms(2500);
Lcd_Cmd(_LCD_CLEAR);}                       // LIMPA A TELA DO LCD
else {
Lcd_Out(1, 1, msg_5);                       
Lcd_Out(2, 1, msg_6);
}                                                                  // FIM ELSE
 }                                                               // FIM  WHILE
  }                                                                // FIM MAIN
Beispiel #30
0
void interrupt() {
    if (INTCON.TMR0IF) {
     counter++;
     TMR0 = 131;
     INTCON.TMR0IF = 0;
      if (counter = 1000) {
       counter =0;
       segundos++;
       if (segundos = 60) {
        segundos = 0;
        minutos++;
         if (minutos = 60) {
          minutos = 0;
          horas++;
          }
        }
       }
     if (segundos==EEPROM_Read(0x02) && minutos==EEPROM_Read(0x03) && horas==EEPROM_Read(0x04)) {
        alimentar(EEPROM_Read(0x01));
      }
     }

}