CYPRESS PSoc4 CY8CKIT-049-42XX 6通道數位電壓表
CYPRESS PSoc4 CY8CKIT-049-42XX 開發粄一片只要 4 美元
前段是USB轉URAT 後段是 PSOC 4200,買來折開前段當USB轉URAT用都太划算!前段拿去當別的開發用了後端當然也不能浪費.
這是為了插入麵包板和好Pin的情形.
之前有買 CY8CKIT-059 就用CY8CKIT-059的SWD,不用另外建uratboot
開啟PSoC Creator -->新專案 --> 選IC (PSoC4200) --> 檔名 -->畫線路圖
前段是USB轉URAT 後段是 PSOC 4200,買來折開前段當USB轉URAT用都太划算!前段拿去當別的開發用了後端當然也不能浪費.
這是為了插入麵包板和好Pin的情形.
開啟PSoC Creator -->新專案 --> 選IC (PSoC4200) --> 檔名 -->畫線路圖
ADCmux 內容
IC 腳位配置圖
寫 main.C
/* ========================================
*
* Copyright YOUR COMPANY, THE YEAR
* All Rights Reserved
* UNPUBLISHED, LICENSED SOFTWARE.
*
* CONFIDENTIAL AND PROPRIETARY INFORMATION
* WHICH IS THE PROPERTY OF your company.
*
* ========================================
*/
#include <printf.h>
#include "Nokia5110LCD.h"
#include <ADCmux.h>
void initHarware()
{
CyGlobalIntEnable; //啟動中斷
ADCmux_Start(); //啟動ADC
ADCmux_StartConvert(); //開始轉換
}
char buffer[16]; //字元暫存
int16 result; //ADC 轉換後數值
int main() //主程式
{
initHarware(); //
LCD_Init(); //
for(;;)
{
ADCmux_IsEndConversion(ADCmux_WAIT_FOR_RESULT); // 等待ADC中斷
result = ADCmux_GetResult16(0) / 2 ; // ADC0 的值 /2 存入 result
LCD_Clear(); //清除LCD
sprintf(buffer, "Ch0= %d", result); // "Ch0= %d" result 轉成ASCII 存回 beffer
LCD_gotoXY(0,0); //LCD 游標回0,0
LCD_String(buffer); //LCD 顯示 buffer 內容
LCD_gotoXY(63,0); //LCD 游標 63,0
LCD_String("mV"); //顯示 mV 字元
result = ADCmux_GetResult16(1) / 2 ; //第二通道
sprintf(buffer, "Ch1= %d", result);
LCD_gotoXY(0,1);
LCD_String(buffer);
LCD_gotoXY(63,1);
LCD_String("mV");
result = ADCmux_GetResult16(2) / 2 ;
sprintf(buffer, "Ch2= %d", result);
LCD_gotoXY(0,2);
LCD_String(buffer);
LCD_gotoXY(63,2);
LCD_String("mV");
result = ADCmux_GetResult16(3) / 2 ;
sprintf(buffer, "Ch0= %d", result);
LCD_gotoXY(0,3);
LCD_String(buffer);
LCD_gotoXY(63,3);
LCD_String("mV");
result = ADCmux_GetResult16(4) / 2 ;
sprintf(buffer, "Ch1= %d", result);
LCD_gotoXY(0,4);
LCD_String(buffer);
LCD_gotoXY(63,4);
LCD_String("mV");
result = ADCmux_GetResult16(5) / 2 ;
sprintf(buffer, "Ch2= %d", result);
LCD_gotoXY(0,5);
LCD_String(buffer);
LCD_gotoXY(63,5);
LCD_String("mV");
CyDelay(1000); //延遲一秒
}
}
/* [] END OF FILE */
快速鍵 Ctrl + F5 完成
沒有留言:
張貼留言