GithubHelp home page GithubHelp logo

lab04-io's Introduction

Lab04-IO

Lab 04 được demo trên micro-controller TIVA LaunchPad TM4C123G IMG_7908

Mô tả

Hệ thống gồm hai switch tích cực mức thấp SW1, SW2 có vai trò input (nối với các chân PF4 và PF0) và ba output (PF3,PF2,PF1) được nối đến một LED nhiều màu.

Screen Shot 2019-03-29 at 16 40 31

Các tasks được thực hiện trong Lab này:

  1. Sử dụng datasheet để check địa chỉ của các thanh ghi và gán chúng với tên có nghĩa. Ví dụ, xét GPIO DIRECTION của Port F. Base address của GPIO Port F là 0x40025000, địa chỉ offset của GPIO DIRECTION là 0x400. Vậy, gán địa chỉ 0x40025400 cho biến toàn cục GPIO_PORTF_DIR_R và sử dụng nó để truy cập đến GPIO DIR của PORT F.
#define GPIO_PORTF_DIR_R        (*((volatile unsigned long *)0x40025400))
  1. Khởi tạo Port: bao gồm các bước

    • Kích hoạt clock cho Port
    • Tắt analog function trong thanh ghi GPIO_AMSEL
    • Clear bits trong thanh ghi PCTL
    • Set input/output
    • Clear bits trong thanh ghi Alternate function (GPIO_AFSEL)
    • Bật digital port trong thanh ghi GPIO_DEN
  2. Bit masking: dùng toán tử logic AND và OR để set/clear các bit cần thiết, giữ nguyên trạng thái của các bit còn lại. Ví dụ, Port F là một output, mình muốn set bit 5 và clear bit 3.

GPIO_PORTF_DATA_R = (GPIO_PORTF_DATA_R&(~0x08))|0x20;

Video demo

Phần demo ngắn có thể được tìm tại đây được hỗ trợ bởi khoá học MOOC Embedded Systems - Shape The World: Microcontroller Input/Output của giáo sư Jonathan Valvano của Đại học Texas tại Austin.

lab04-io's People

Contributors

hoangquochung1110 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.