#include "lcd.h"
#include "stdlib.h"
#include "font.h"
#include "stdarg.h"
#define LCD_CMD ((u32)0x6001FFFF)
#define LCD_DATA ((u32)0x60020000)
#define LCD_CLEAR_SEND_NUMBER 5760
u16 BACK_COLOR = BLACK, FORE_COLOR = WHITE;
void lcd_write_cmd(const u8 cmd)
{
*(__IO u8*)LCD_CMD=cmd;
}
void lcd_write_data(const u8 data)
{
*(__IO u8*)LCD_DATA=data;
}
void lcd_write_half_word(const u16 da)
{
*(__IO u8*)LCD_DATA=(u8)(da>>8);
*(__IO u8*)LCD_DATA=(u8)da;
}
u8 lcd_read_data(void)
{
vu8 ram;
ram = *(__IO u8*)LCD_DATA;
return ram;
}
u8 lcd_read_reg(const u8 reg)
{
lcd_write_cmd(reg);
delay_us(5);
return lcd_read_data();
}
void lcd_fsmc_init(void)
{
GPIO_InitTypeDef GPIO_InitStructure={0};
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure={0};
FSMC_NORSRAMTimingInitTypeDef readWriteTiming={0};
FSMC_NORSRAMTimingInitTypeDef writeTiming={0};
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE|RCC_APB2Periph_GPIOG,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_14|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* RS--D12 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* CS: PD11*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_ResetBits(GPIOD,GPIO_Pin_11);
readWriteTiming.FSMC_AddressSetupTime = 0x01;
readWriteTiming.FSMC_AddressHoldTime = 0x00;
readWriteTiming.FSMC_DataSetupTime = 0x0f;
readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
readWriteTiming.FSMC_CLKDivision = 0x00;
readWriteTiming.FSMC_DataLatency = 0x00;
readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A;
writeTiming.FSMC_AddressSetupTime = 0x00;
writeTiming.FSMC_AddressHoldTime = 0x00;
writeTiming.FSMC_DataSetupTime = 0x03;
writeTiming.FSMC_BusTurnAroundDuration = 0x00;
writeTiming.FSMC_CLKDivision = 0x00;
writeTiming.FSMC_DataLatency = 0x00;
writeTiming.FSMC_AccessMode = FSMC_AccessMode_A;
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
}
/*******************************************************************************
* Function Name : TIM1_PWMOut_Init
* Description : Initializes TIM1 PWM output.
* Input : arr: the period value.
* psc: the prescaler value.
* ccp: the pulse value.
* Return : None
*******************************************************************************/
void TIM1_PWMOut_Init( u16 arr, u16 psc, u16 ccp )
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB | RCC_APB2Periph_TIM1, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOB, &GPIO_InitStructure );
TIM_TimeBaseInitStructure.TIM_Period = arr;
TIM_TimeBaseInitStructure.TIM_Prescaler = psc;
TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit( TIM1, &TIM_TimeBaseInitStructure);
#if (PWM_MODE == PWM_MODE1)
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
#elif (PWM_MODE == PWM_MODE2)
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
#endif
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = ccp;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init( TIM1, &TIM_OCInitStructure );
TIM_CtrlPWMOutputs(TIM1, ENABLE );
TIM_OC1PreloadConfig( TIM1, TIM_OCPreload_Disable );
TIM_ARRPreloadConfig( TIM1, ENABLE );
TIM_Cmd( TIM1, ENABLE );
}
void lcd_gpio_init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_SetBits(GPIOD,GPIO_Pin_13);
GPIO_ResetBits(GPIOD,GPIO_Pin_13);
//wait at least 100ms for reset
delay_ms(100);
GPIO_SetBits(GPIOD,GPIO_Pin_13);
// TIM1_PWMOut_Init( 1000, 48000-1, 50 );
}
void lcd_init(void)
{
u16 id=0;
lcd_gpio_init();
lcd_fsmc_init();
lcd_write_cmd(0X04);
id = lcd_read_data(); //dummy read
id = lcd_read_data(); //读到0X85
id = lcd_read_data(); //读取0X85
id <<= 8;
id |= lcd_read_data(); //读取0X52
printf("id = %x\r\n",id);
delay_ms(50);
/* Memory Data Access Control */
lcd_write_cmd(0x36);
lcd_write_data(0x00);
/* RGB 5-6-5-bit */
lcd_write_cmd(0x3A);
lcd_write_data(0x05);
/* Porch Setting */
lcd_write_cmd(0xB2);
lcd_write_data(0x0C);
lcd_write_data(0x0C);
lcd_write_data(0x00);
lcd_write_data(0x33);
lcd_write_data(0x33);
/* Gate Control */
lcd_write_cmd(0xB7);
lcd_write_data(0x00);
/* VCOM Setting */
lcd_write_cmd(0xBB);
lcd_write_data(0x3F);
/* LCM Control */
lcd_write_cmd(0xC0);
lcd_write_data(0x2C);
/* VDV and VRH Command Enable */
lcd_write_cmd(0xC2);
lcd_write_data(0x01);
/* VRH Set */
lcd_write_cmd(0xC3);
lcd_write_data(0x0D);
/* VDV Set */
lcd_write_cmd(0xC4);
lcd_write_data(0x20);
/* Frame Rate Control in Normal Mode */
lcd_write_cmd(0xC6);
lcd_write_data(0x03); //60Hz-0x0F 82Hz-0x07 99Hz-0x03
/* Power Control 1 */
lcd_write_cmd(0xD0);
lcd_write_data(0xA4);
lcd_write_data(0xA1);
/* Positive Voltage Gamma Control */
lcd_write_cmd(0xE0);
lcd_write_data(0xF0);
lcd_write_data(0x03);
lcd_write_data(0x09);
lcd_write_data(0x03);
lcd_write_data(0x03);
lcd_write_data(0x10);
lcd_write_data(0x2D);
lcd_write_data(0x43);
lcd_write_data(0x3F);
lcd_write_data(0x33);
lcd_write_data(0x0D);
lcd_write_data(0x0E);
lcd_write_data(0x29);
lcd_write_data(0x32);
/* Negative Voltage Gamma Control */
lcd_write_cmd(0xE1);
lcd_write_data(0xF0);
lcd_write_data(0x0C);
lcd_write_data(0x10);
lcd_write_data(0x0E);
lcd_write_data(0x0E);
lcd_write_data(0x0A);
lcd_write_data(0x2D);
lcd_write_data(0x33);
lcd_write_data(0x45);
lcd_write_data(0x3A);
lcd_write_data(0x14);
lcd_write_data(0x19);
lcd_write_data(0x31);
lcd_write_data(0x37);
/* Display Inversion On */
lcd_write_cmd(0x21);
/* Sleep Out */
lcd_write_cmd(0x11);
/* wait for power stability */
delay_ms(100);
lcd_clear(BLACK);
/* display on */
GPIO_SetBits(GPIOB,GPIO_Pin_14);
lcd_write_cmd(0x29);
}
/**
* Set background color and foreground color
*
* @param back background color
* @param fore fore color
*
* @return void
*/
void lcd_set_color(u16 back, u16 fore)
{
BACK_COLOR = back;
FORE_COLOR = fore;
}
void lcd_display_on(void)
{
GPIO_SetBits(GPIOB,GPIO_Pin_14);
}
void lcd_display_off(void)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_14);
}
/* lcd enter the minimum power consumption mode and backlight off. */
void lcd_enter_sleep(void)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_14);
delay_ms(5);
lcd_write_cmd(0x10);
}
/* lcd turn off sleep mode and backlight on. */
void lcd_exit_sleep(void)
{
GPIO_SetBits(GPIOB,GPIO_Pin_14);
delay_ms(5);
lcd_write_cmd(0x11);
delay_ms(120);
}
/**
* Set drawing area
*
* @param x1 start of x position
* @param y1 start of y position
* @param x2 end of x position
* @param y2 end of y position
*
* @return void
*/
void lcd_address_set(u16 x1, u16 y1, u16 x2, u16 y2)
{
lcd_write_cmd(0x2a);
lcd_write_data(x1 >> 8);
lcd_write_data(x1);
lcd_write_data(x2 >> 8);
lcd_write_data(x2);
lcd_write_cmd(0x2b);
lcd_write_data(y1 >> 8);
lcd_write_data(y1);
lcd_write_data(y2 >> 8);
lcd_write_data(y2);
lcd_write_cmd(0x2C);
}
/**
* clear the lcd.
*
* @param color Fill color
*
* @return void
*/
void lcd_clear(u16 color)
{
u16 i, j;
u8 data[2] = {0};
data[0] = color >> 8;
data[1] = color;
lcd_address_set(0, 0, LCD_W - 1, LCD_H - 1);
/* 5760 = 240*240/20 */
for (i = 0; i < LCD_W; i++)
{
for (j = 0; j < LCD_H; j++)
{
*(__IO u8*)LCD_DATA=data[0];
*(__IO u8*)LCD_DATA=data[1];
}
}
}
/**
* display a point on the lcd.
*
* @param x x position
* @param y y position
*
* @return void
*/
ME7660 是一 DC/DC 电荷泵电压反转器专用集成电路 芯片采用成熟的 AL 栅 CMOS工艺及优化的设计
芯片能将输入范围为+1.5V至+10V的电压转换成相应的-1.5V 至-10V 的输出
并且只需外接两只低损耗电容 无需电感 降低了损耗 面积及电磁干 扰 芯片的振荡器额定频率为 10KHZ 应用于低输入电流情况时 可于振荡器与地之间 外接一电容
从而以低于 10KHZ 的振荡频率正常工作
特点
1 转换逻辑电源+5V 为 5V 双相电压
2 输入工作电压范围广 1.5V 10V
3 电压转换精度高 99.9%
4 电源转换效率高 98% 5 低功耗 静态电流为 90 A(输入 5V 时)
6 外围元器件少 便于使用 只需两只外接电容
7 8-Pin DIP 和 8-Pin SOIC 小封装 8 符合 RS232 负电压标准 9 静电击穿电压高 可达 3KV 10 高电压工作时 无 Dx 二极管需求
用途我猜测是
(一)当电压发生反转时,示波器能够清晰地显示出这种反转现象,包括反转的起始点、持续时间以及反转后的电压幅值等关键参数。
(二)当电压信号发生反转时,示波器电压反转器(或类似功能)能够捕捉并显示这种变化
运算放大器
GS8094
在我的理解里
(一)运放可以增强微弱信号的幅度,使其更容易在示波器屏幕上显示和观测。
(二)对输入信号进行初步放大,以确保信号在后续处理过程中保持足够的幅度和信噪比。
(三)高质量的运算放大器通常具有极低的噪声水平,这有助于减少测量过程中的噪声干扰,提高测量精度。
输入失调电压(Vos) : 8mV
电源抑制比(PSRR) : 80dB
存储温度 : -55~+150℃
封装/外壳 : SOP14_150MIL
-3db带宽 : 350MHz
通道数 : 4
输入偏置电流 : 1pA
压摆率 : 232V/μs
增益带宽积(GBP) : 195MHz
共模抑制比 - CMRR : 80dB
输出类型 : Rail-to-Rail
工作温度 : -40℃~+125℃
长x宽/尺寸 : 8.63 x 3.90mm
高度 : 1.75mm
引脚数 : 14Pin
脚间距 : 1.27mm
#define NPT 1024//一次完整采集的采样点数
/******************************************************************
函数名称:GetPowerMag()
函数功能:计算各次谐波幅值
参数说明:
备 注:先将lBufOutArray分解成实部(X)和虚部(Y),然后计算幅值(sqrt(X*X+Y*Y)
*******************************************************************/
void GetPowerMag(void)
{
float X,Y,Mag,magmax;//实部,虚部,各频率幅值,最大幅值
u16 i;
//调用自cr4_fft_1024_stm32
cr4_fft_1024_stm32(fftout, fftin, NPT);
//fftin为傅里叶输入序列数组,ffout为傅里叶输出序列数组
for(i=1; i2; i++)
{
X = (fftout << 16) >> 16;
Y = (fftout >> 16);
Mag = sqrt(X * X + Y * Y);
FFT_Mag=Mag;//存入缓存,用于输出查验
//获取最大频率分量及其幅值
if(Mag > magmax)
{
magmax = Mag;
temp = i;
}
}
F=(u16)(temp*(fre*1.0/NPT));//源代码中此公式有误,将此复制进去
LCD_ShowNum(280,180,F,5,16);
}
u16 magout[NPT];
/******************************************************************
函数名称:InitBufInArray()
函数功能:正弦波值初始化,将正弦波各点的值存入magout[]数组中
参数说明:
备 注:
*******************************************************************/
void InitBufInArray(void)
{
u16 i;
float fx;
for(i=0; isin((PI2*i)/NPT);
magout = (u16)(2048+2048*fx);
}
}
/******************************************************************
函数名称:sinout()
函数功能:正弦波输出
参数说明:
备 注:将此函数置于定时器中断中,可模拟输出正弦波
*******************************************************************/
void sinout(void)
{
static u16 i=0;
DAC_SetChannel1Data(DAC_Align_12b_R,magout);
i++;
if(i>=NPT)
i=0;
}
作者: 小恶魔owo, 来源:面包板社区
链接: https://mbb.eet-china.com/blog/uid-me-4067534.html
版权声明:本文为博主原创,未经本人允许,禁止转载!
乖乖兔爸爸 2024-9-27 10:15
100块 的成本的确很良心, 网上还有更便宜的, 30块左右的散件
我一直想找一款: 居家可用,的, 能测 千兆 以太网 (125M 时钟) 的便宜示波器, 有相关信息的大侠欢迎留言