My Link

Photobucket

Bahasa program untuk Mikrokontroler

Jadi, Anda ingin memulai pemrograman dan mikrokontroler menggunakan dalam proyek Anda, tetapi di mana Anda mulai assembler, BASIC, C atau Pascal. Each of the languages has different strengths and weaknesses which you need to consider before starting out. Setiap bahasa memiliki kekuatan dan kelemahan yang perlu Anda perhatikan sebelum memulai.

Assembler

Assembler is the most obvious language that you'll consider using Assembler adalah bahasa yang paling jelas bahwa Anda akan mempertimbangkan untuk menggunakan
as you probably won't need to buy any other tools to use it. karena anda mungkin tidak perlu membeli alat-alat lain untuk menggunakannya. More Lebih
than likely the manufacturer will provide an assembler for the kemungkinan besar produsen akan menyediakan assembler untuk
chip and you won't need any books as all the instructions are in chip dan Anda tidak akan membutuhkan buku-buku karena semua instruksi berada di
the datasheet and you just start coding. datasheet dan Anda baru saja mulai coding.

This route to programming is very easy but you may be setting Ini rute ke pemrograman sangat mudah, tetapi Anda mungkin pengaturan
yourself up for problems later on as: diri untuk masalah di kemudian hari sebagai:
  1. It is trivial to write short programs. Hal ini sepele untuk menulis program pendek.
  2. It becomes progressively more difficult to write large programs. Hal ini menjadi semakin sulit untuk menulis program besar.
  3. It seems to be the best option as it gives the fastest code. Hal ini tampaknya menjadi pilihan terbaik karena memberikan kode tercepat.
  4. It seems to be the best option as it gives the smallest code. Hal ini tampaknya menjadi pilihan terbaik karena memberikan kode terkecil.

Assembler: Fast & small code Assembler: Cepat & kecil kode

There is no doubt that assembler gives the fastest and most optimized code (your brain is better at optimization than any compiler!) but assembler is difficult – typically you'll spend ten times as long writing assembler as you would writing in a high level language. Tidak ada keraguan bahwa assembler memberikan dan paling optimal kode tercepat (otak Anda lebih baik pada optimasi dari compiler manapun!) Tetapi perakit sulit - biasanya Anda akan menghabiskan sepuluh kali sebagai perakit menulis selama Anda akan menulis dalam bahasa tingkat tinggi .

Assembler / Compiler Trade off Assembler / Compiler Trade off

This is the trade off; to write the fastest most optimized code or to get the task solved more quickly. Ini adalah trade off, untuk menulis kode yang paling optimal tercepat atau untuk mendapatkan tugas diselesaikan lebih cepat.

Another problem with assembler is that to do even the most trivial task you have to think about every aspect of the code and all implications on registers and register flags. Masalah lain dengan assembler adalah bahwa untuk melakukan bahkan yang sepele tugas yang paling Anda harus berpikir tentang setiap aspek kode dan segala implikasinya pada register dan mendaftar bendera.

Even making a microcontroller perform the most trivial task is difficult eg for making a loop in assembler you need to think about which register to use and which instructions all the while thinking about how those registers should not interact with the loop register/other registers etc. Bahkan membuat mikrokontroler melakukan tugas yang paling sepele adalah misalnya sulit untuk membuat sebuah loop dalam assembler Anda harus berpikir tentang yang mendaftar untuk menggunakan dan yang instruksi semua sambil berpikir tentang bagaimana orang-register tidak harus berinteraksi dengan register loop / register lainnya dll

Assembler: Problem - changing the target Assembler: Masalah - mengubah target

Another difficulty is when you change from one microcontroller to another (even in the same device family) the assembler instructions may be changed eg more instructions to improve microcontroller performance. kesulitan lain adalah ketika Anda mengubah dari satu mikrokontroler lain (bahkan dalam keluarga perangkat yang sama) petunjuk assembler dapat berubah misalnya petunjuk lebih lanjut untuk meningkatkan kinerja mikrokontroler. So you will have to learn an entirely different instruction set when moving either to a new target microcontroller or moving to a different device within the same family ie code re-use is not possible unless you stay with one microcontroller (or devices with a similar internal architecture). Jadi, Anda akan harus belajar yang berbeda sama sekali instruksi set ketika pindah baik ke mikrokontroler target baru atau pindah ke perangkat yang berbeda dalam-sama keluarga yaitu menggunakan kode ulang tidak mungkin kecuali Anda tinggal dengan satu mikrokontroler (atau perangkat dengan serupa internal arsitektur).

High level languages Bahasa tingkat tinggi


HLL: target ulang

Retargeting code to another microcontroller is easier since the HLL will know the details of the new target ie instruction set, fuses etc. Retargeting kode untuk mikrokontroler lain lebih mudah karena HLL akan mengetahui rincian set target yaitu instruksi baru, sekering dll All you need to worry about is the specific differences between the different microcontrollers (in the same family this will be setting up the internal peripherals). Yang perlu Anda khawatirkan adalah perbedaan khusus antara mikrokontroler yang berbeda (dalam keluarga yang sama ini akan disiapkan periferal internal).

The important point is that the HLL takes care of the assembler code needed to do the job. Yang penting adalah bahwa HLL menangani kode assembler yang diperlukan untuk melakukan pekerjaan.

HLL: Easy to understand. HLL: Mudah dimengerti.

The most useful aspect of a high level language (HLL) is that the language is written in a form you can easily understand – there are no cryptic assembler commands that you have to remember and most commands are made up of several machine code instructions – saving you coding effort (often there are built in libraries of code eg LCD driver, Serial port driver, I2C driver etc. Yang berguna Aspek yang paling dari bahasa tingkat tinggi (HLL) adalah bahwa bahasa ditulis dalam bentuk Anda dapat dengan mudah mengerti - tidak ada perintah assembler samar bahwa Anda harus ingat dan perintah sebagian besar terdiri dari beberapa instruksi kode mesin - tabungan Anda coding usaha (sering terdapat dibangun di perpustakaan kode misalnya driver LCD, driver port Serial, I2C driver dll

So the HLL makes it easy to write code as it generates the correct assembler for the target microcontroller. Jadi HLL memudahkan untuk menulis kode karena menghasilkan assembler yang benar untuk mikrokontroler target.

HLL : Whitespace HLL: Whitespace

You can also make use of white space (areas of no code) to separate out the various operations within the program – typically assembler code is just one great big list that is really very difficult to read – I know there are comments but you need to comment almost every line so that someone else can Anda juga dapat menggunakan ruang putih (bidang kode tidak) untuk memisahkan berbagai operasi dalam program - biasanya kode assembler adalah salah satu daftar besar besar yang benar-benar sangat sulit untuk dibaca - saya tahu ada komentar tetapi Anda perlu komentar hampir setiap baris sehingga orang lain dapat
understand the code. memahami kode.

HLL: Task splitting HLL: Tugas membelah

One of the best features of a HLL is that you can split tasks into separate functions that you can concentrate on them individually (as the HLL takes care of local variables etc.). Salah satu fitur terbaik dari sebuah HLL adalah bahwa Anda dapat membagi tugas ke dalam fungsi yang terpisah yang dapat Anda berkonsentrasi pada mereka secara individu (sebagai HLL menangani variabel lokal dll). For assembler even when using a call instruction you have to take care of preserving the register state – in the HLL it's all done Untuk assembler bahkan ketika menggunakan sebuah panggilan instruksi Anda harus mengurus melestarikan negara register - di HLL itu semua dilakukan
for you. untuk Anda.

HLL: Code re-use HLL: Kode digunakan kembali

Once you learn the HLL you will find it easy to read code written by other people and you will be able to re-use code that you have already written whereas with assembler you will constantly need to analyze the code to see if it fits in with your new functions. Setelah Anda mempelajari HLL Anda akan merasa mudah untuk membaca kode yang ditulis oleh orang lain dan Anda akan dapat menggunakan kode-ulang bahwa Anda sudah menulis bahwa dengan assembler Anda akan selalu perlu untuk menganalisis kode untuk melihat apakah cocok dengan Anda baru fungsi.

The only decision then is which high level language? Keputusan-satunya kemudian yang bahasa tingkat tinggi? There are really three contenders BASIC, C and Pascal – these are the most popular languages and for popular microcontrollers there will be an HLL compiler for each one. Sesungguhnya ada tiga pesaing BASIC, C dan Pascal - ini adalah bahasa yang paling populer dan untuk mikrokontroler populer akan ada compiler HLL untuk masing-masing. I'll just list the advantages and disadvantages of each Aku hanya akan mencantumkan kelebihan dan kekurangan masing-masing

BASIC Advantages DASAR Keuntungan

  1. Very easy to learn and use. Sangat mudah dipelajari dan digunakan.
  2. A BASIC compiler will produce code that runs fast as a C compiler. Sebuah kompiler DASAR akan menghasilkan kode yang berjalan cepat sebagai kompiler C.
  3. Many in built functions (depending on compiler). Banyak fungsi yang dibangun (tergantung compiler).
  4. Very popular – large user base with many example programs. Sangat populer - besar basis pengguna dengan banyak contoh program.

BASIC Disadvantages DASAR Kekurangan

  1. Non standard language. Non bahasa baku.
  2. If using an interpreted HLL will run very slowly. Jika menggunakan HLL ditafsirkan akan berjalan sangat lambat.

Note: Because the language is not standardized it will be difficult to move code to a new processor target type. Catatan: Karena bahasa tidak standar akan sulit untuk memindahkan kode untuk jenis prosesor baru target.

Pascal Advantages Keuntungan pascal

  1. Easy to learn and use. Mudah dipelajari dan digunakan.
  2. A Pascal compiler will produce code that runs fast as a C compiler. Sebuah kompiler Pascal akan menghasilkan kode yang berjalan cepat sebagai kompiler C.
  3. Many in built functions (depending on compiler). Banyak fungsi yang dibangun (tergantung compiler).

Pascal Disadvantages Pascal Kekurangan

  1. Not as popular as C – so not as many compilers. Tidak sepopuler C - sehingga tidak banyak kompiler.
  2. A bit wordy – it was originally intended as a teaching language. A bit bertele-tele - itu awalnya ditujukan sebagai bahasa pengajaran.
  3. Not as flexible as C. Bukan sebagai fleksibel sebagai C.

C Advantages Keuntungan C

  1. Compiled language - always runs fast. Bahasa Dikompilasi - selalu berjalan cepat.
  2. Standardized language (ANSI)- easier to port to different compilers / target devices. Bahasa standar (ANSI) - lebih mudah untuk port ke compiler yang berbeda / perangkat target.
  3. Many compilers available. Banyak kompiler yang tersedia.
  4. Many in built functions (depending on compiler). Banyak fungsi yang dibangun (tergantung compiler).
  5. Very popular – large user base with many example programs. Sangat populer - besar basis pengguna dengan banyak contoh program.
  6. Used in many different industries. Digunakan dalam berbagai industri.
  7. Usable at the hardware level as well as higher abstraction levels (although C++ is better for very abstracted programming models). Dapat digunakan di tingkat perangkat keras serta tingkat abstraksi yang lebih tinggi (walaupun C + + adalah lebih baik bagi pemrograman model sangat abstrak).

C Disadvantages C Kekurangan

  1. Hard to learn at first. Sulit untuk belajar pada awalnya.
  2. Strong type checking means you spend time pleasing the compiler (although this protects you from making errors). memeriksa jenis kuat berarti Anda menghabiskan waktu menyenangkan compiler (walaupun ini melindungi Anda dari kesalahan pembuatan).

0 komentar: