本文講解了國產A40i 開發板PWM的應用,本篇文章主要適用于飛凌 OKA40i 平臺 Linux3.10.65 操作系統,其他arm 平臺也可以參考,但是不同平臺之間會存在差異,請自行修改以適應自己的使用。 寫本文章的主要目的是協助客戶加速產品的研發速度,由于水平有限, 不提供任何的完整性、可靠性等保證,軟件版本更新之后,有些位置名稱等內容可能會及時更新,修改方法請參考使用。
FETA40i-C核心板基于全志工控行業平臺級處理器四核Cortex-A7 A40i設計,主頻1.2GHz,集成MAli400MP2GPU,內存1GB/2GB DDR3L,存儲8GB eMMC。支持絕大部分當前流行的視頻及圖片格式解碼,具有穩定可靠的工業級產品性能和高性價比低功耗等優勢,搭載Linux和Android操作系統,適用于基于視覺交互的工業控制產品,目標應用包含,嵌入式設備、智能終端、工業控制、數據采集、機器視覺 、工業物聯網 、移動互聯設備、數字標牌 等。
特點:
●全志工業級A40I四核Cortex-A7,主頻最高為1.2GHz,集成Mali400MP2 GPU;
●支持雙屏同顯異顯和多種顯示接口RGB/MIPI /雙8位 LVDS/HDMI/TV OUT,1920x1080@60fps;
●支持1路千兆網絡,1路百兆網絡,支持WIFI/BT4.0,支持4G;
●支持多路攝像頭輸入,兩路DVP攝像頭接口,最高支持500W像素,四路TVIN,支持NTSC與 PAL制式
●CPU內部集成Audio Codec,支持1路差分PHONEOUT,1路立體聲耳機輸出 ,1路microphone輸入
●外部擴展接口豐富UART *8、SD*4、USB*3、SPI *4、IIC*5、SATA、PWM*8等;
●支持Linux和Android操作系統;
正文開始:
一、PWM的應用
1、pwm的添加
增加一路 pwm,以 pwm4 為例說明,其他方法類似,只做為參考。
arch/arm/boot/dts/sun8iw11p1.dtsi
中添加
pwm = &pwm; pwm0 = &pwm0; pwm4 = &pwm4; pwm: pwm@01c23400 { compatible = "allwinner,sunxi-pwm"; reg = <0x0 0x01c23400 0x0 0x154>; pwm-number = <1>; pwm-base = <0x4>; pwms = <&pwm4>; }; pwm4: pwm4@01c23400 { compatible = "allwinner,sunxi-pwm4"; pinctrl-names = "active", "sleep"; reg_base = <0x01c23400>; reg_peci_offset = <0x00>; reg_peci_shift = <0x04>; reg_peci_width = <0x01>; reg_pis_offset = <0x04>; reg_pis_shift = <0x04>; reg_pis_width = <0x01>; reg_crie_offset = <0x10>; reg_crie_shift = <0x08>; reg_crie_width = <0x01>; reg_cfie_offset = <0x10>; reg_cfie_shift = <0x09>; reg_cfie_width = <0x01>; reg_cris_offset = <0x14>; reg_cris_shift = <0x08>; reg_cris_width = <0x01>; reg_cfis_offset = <0x14>; reg_cfis_shift = <0x09>; reg_cfis_width = <0x01>; reg_clk_src_offset = <0x28>; reg_clk_src_shift = <0x07>; reg_clk_src_width = <0x02>; reg_bypass_offset = <0x28>; reg_bypass_shift = <0x05>; reg_bypass_width = <0x01>; reg_clk_gating_offset = <0x28>; reg_clk_gating_shift = <0x04>; reg_clk_gating_width = <0x01>; reg_clk_div_m_offset = <0x28>; reg_clk_div_m_shift = <0x00>; reg_clk_div_m_width = <0x04>; reg_pdzintv_offset = <0x38>; reg_pdzintv_shift = <0x08>; reg_pdzintv_width = <0x08>; reg_dz_en_offset = <0x38>; reg_dz_en_shift = <0x00>; reg_dz_en_width = <0x01>; reg_enable_offset = <0x40>; reg_enable_shift = <0x04>; reg_enable_width = <0x01>; reg_cap_en_offset = <0x44>; reg_cap_en_shift = <0x04>; reg_cap_en_width = <0x01>; reg_period_rdy_offset = <0xe0>; reg_period_rdy_shift = <0x0b>; reg_period_rdy_width = <0x01>; reg_pul_start_offset = <0xe0>; reg_pul_start_shift = <0x0a>; reg_pul_start_width = <0x01>; reg_mode_offset = <0xe0>; reg_mode_shift = <0x09>; reg_mode_width = <0x01>; reg_act_sta_offset = <0xe0>; reg_act_sta_shift = <0x08>; reg_act_sta_width = <0x01>; reg_prescal_offset = <0xe0>; reg_prescal_shift = <0x00>; reg_prescal_width = <0x08>; reg_entire_offset = <0xe4>; reg_entire_shift = <0x10>; reg_entire_width = <0x10>; reg_active_offset = <0xe4>; reg_active_shift = <0x00>; reg_active_width = <0x10>; }
按手冊 PWM 修改對應的寄存器。
修改 sys_config.fex 中 twi2_used=0 且增加
[pwm4] pwm_used = 1 pwm_positive = port:PB20<4><0> [pwm4_suspend] pwm_positive = port:PB20<7><0>
編譯鏡像并燒寫
2、PWM的測試
echo 0 >/sys/class/pwm/pwmchip4/export echo 1000000 > /sys/class/pwm/pwmchip4/pwm0/period echo 500000 > /sys/class/pwm/pwmchip4/pwm0/duty_cycle echo 1 > /sys/class/pwm/pwmchip4/pwm0/enable
測量得到頻率為 1K 方波
echo 0 > /sys/class/pwm/pwmchip4/pwm0/enable echo 208333> /sys/class/pwm/pwmchip4/pwm0/duty_cycle echo 416667 > /sys/class/pwm/pwmchip4/pwm0/period echo 1 > /sys/class/pwm/pwmchip4/pwm0/enable
測量得到頻率為 2.4K 方波
-
芯片
+關注
關注
456文章
51037瀏覽量
425492
發布評論請先 登錄
相關推薦
評論