#include <device.h>
#include <stdbool.h>
#include <project.h>
uint8 lut[100] =
{
127,134,142,150,158,166,173,181,188,195,201,207,213,219,224,229,
234,238,241,245,247,250,251,252,253,253,253,252,251,250,247,245,
241,238,234,229,224,219,213,207,201,195,188,181,173,166,158,150,
142,134,126,119,111,103, 95, 87, 80, 72, 65, 58, 52, 46, 40, 34,
29, 24, 19, 15, 12, 8, 6, 3, 2, 1, 0, 0, 0, 1, 2, 3,
6, 8, 12, 15, 19, 24, 29, 34, 40, 46, 52, 58, 65, 72, 80, 87,
95,103,111,119
};
#define DMA_1_BYTES_PER_BURST 1
#define DMA_1_REQUEST_PER_BURST 1
#define DMA_1_SRC_BASE (CYDEV_PERIPH_BASE)
#define DMA_1_DST_BASE (CYDEV_PERIPH_BASE)
reg8 *Regpoint;
void main()
{
void DMA_SET();
cystatus eraseStatus;
cystatus writeStatus;
EEPROM_1_Start();
LCD_1_Start();
VDAC8_1_Start();
uint16 index=0;
uint16 error=0;
uint8 number=0;
bool flag;
for(;index<=EEPROM_NUMBER_SECTORS;index++)
{
eraseStatus=EEPROM_1_EraseSector(index);
}
Regpoint=(reg8*)CYDEV_EE_BASE;
for(index=0;index<=EEPROM_1_EEPROM_SIZE;index++)
{
if(Regpoint[index]!=0)
{
LCD_1_Position(0,0);
LCD_1_PrintString("ERROR");
error++;}
}
CySetTemp();
for(index=0;index<=7;index++)
{
writeStatus=EEPROM_1_Write(lut+number,index);
number+=16;
}
Regpoint=(reg8*)CYDEV_EE_BASE;
for(index=0;index<100;index++)
{
if(Regpoint[index]!=lut[index])
{
LCD_1_Position(0,0);
LCD_1_PrintString("ERROR");
error++;
}
}
if(error==0)
{
LCD_1_Position(0,0);
LCD_1_PrintString("SUCCESS");
flag=true;
}
else
{
LCD_1_Position(0,0);
LCD_1_PrintString("ERROR");
}
if(flag==true)
{
Regpoint=(reg8*)CYDEV_EE_BASE;
LCD_1_Position(1,0);
LCD_1_PrintString("voltage:");
for(;;)
{DMA_SET();
if(Status_1_Read())
{
LCD_1_Position(1,strlen("voltage:"));
LCD_1_PrintInt8(VDAC8_1_Data);
}
}
}
}
/* [] END OF FILE */
void DMA_SET()
{ uint8 DMA_1_Chan;
uint8 DMA_1_TD[1];
DMA_1_Chan = DMA_1_DmaInitialize(DMA_1_BYTES_PER_BURST, DMA_1_REQUEST_PER_BURST,
HI16(DMA_1_SRC_BASE), HI16(DMA_1_DST_BASE));
DMA_1_TD[0] = CyDmaTdAllocate();
CyDmaTdSetConfiguration(DMA_1_TD[0], 1, DMA_1_TD[0], TD_INC_SRC_ADR);
CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)Regpoint), LO16((uint32)VDAC8_1_Data_PTR));
CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);
CyDmaChEnable(DMA_1_Chan, 1);
} |
|