![]() |
|
Tài trợ cho PIC Vietnam |
||||||||
| PIC32 - Bộ điều khiển tín hiệu số 32-bit Microchip công bố sản phẩm vi xử lý 32-bit ngày 06/11/2007 |
![]() |
|
|
Ðiều Chỉnh | Xếp Bài |
|
|
#1 |
|
PIC Bang chủ
|
Làm quen với PIC32 từ bước đầu
Trong loạt bài viết này, F sẽ cùng các bạn tổng hợp lại các vấn đề về PIC32. Những vẫn đề các bạn thảo luận ở dưới đây sẽ được tổng hợp và đưa lên trên này để tham khảo.
1. Công cụ làm việc Tất nhiên là các bạn không thể quên thằng MPLAB được! Programmer, Bootloader, Debugger, Emulator: Các mạch demo cho PIC32: Chương trình dịch cho PIC32: Xem bảng so sánh tại đây. http://microchip.com/stellent/idcplg...GE&nodeId=2602 2. Tìm hiểu về tập lệnh cho PIC32MX (MIPS32 Release 2) Kiến trúc MIPS32 có thể tìm thấy ở đây: http://www.mips.com/products/resourc...-architecture/ Để thuận tiện cho các bạn download (vì phải đăng ký mới download được), F upload các file đó ở dưới bài viết này. Bài toán "Tháp Hà Nội" ở bên dưới giúp các bạn làm quen với việc lập trình sử dụng MIPS32. MIPS32 Instruction Set Quick Reference MIPS32 DSP ASE Instruction Set Quick Reference Các bạn chú ý download tài liệu này, nó rất cần thiết vì nó là bản đầy đủ của tập lệnh. MIPS32® Architecture For Programmers Volume II: The MIPS32® Instruction Set 3. Tìm hiểu trình dịch cho PIC32: Đây là tài liệu tham khảo để lập trình với C32 của Microchip được Microchip giới thiệu: The ANSI C Programming Language 2nd edition MPLAB C32 Compiler: Đây là chương trình dịch PIC Việt Nam chọn làm cơ sở nghiên cứu PIC32. Basic cho PIC32 (MiniBASIC): http://www.pic32.org/minibasic/ Tài liệu tham khảo: [1] PIC32 Overview Brochure [2] Getting Started with PIC32 [3] PIC32MX Family Datasheet [4] PIC32 Family Reference Manual- All Chapters [5] AN1108 - Microchip TCP/IP Stack with BSD Socket API for PIC32MX [6] AN1107 - HTTP Server using BSD Socket API for PIC32MX [7] AN1109 - SNMP Agent using BSD Socket API for PIC32MX [8] AN1111 - FTP Server using BSD Socket API for the PIC32MX [9] PIC32 Example Source Code - All Files [10] PIC32 Starter Kit Users Guide [11] PIC32MX Programming Spec [12] PIC32MX Family Rev. B2 Silicon Errata Chúc vui
__________________
Công ty TNHH Thương mại và Giao nhận R&P store.hn@rpc.vn - store.hcm@rpc.vn Học PIC như thế nào? thay đổi nội dung bởi: falleaf, 22-01-2008 lúc 05:56 PM. |
|
|
|
|
|
#2 |
|
PIC Bang chủ
|
Tháp Hà Nội
Thử với tập lệnh MIPS32 xem sao nhé
![]() Code:
##
## hanoi.a - recursive implementation of the
## towers of hanoi
##
##
#################################################
# #
# text segment #
# #
#################################################
.text
.globl __start
__start:
la $a0,tower1 # source
la $a1,tower2 # destination
la $a2,tower3 # temporary
lw $a3,numRings
jal moveStack # call procedure
jal PrintTowers # Print answer
li $v0,10
syscall # au revoir...
#------------------------------------------------
# moveStack - recursive implementation of the
# towers of hanoi
# a0 - source tower
# a1 - destination tower
# a2 - spare tower
# a3 - number of rings
# s0 - source tower
# s1 - destination tower
# s2 - spare tower
#------------------------------------------------
moveStack:
sub $sp,$sp,32 # save registers on stack
sw $a0,0($sp)
sw $a1,4($sp)
sw $a2,8($sp)
sw $a3,12($sp)
sw $s0,16($sp)
sw $s1,20($sp)
sw $s2,24($sp)
sw $ra,28($sp)
beq $a3,1,moveOne
# Move one ring only
move $s0,$a0 # keep copy of source tower
move $s1,$a1 # keep copy of destination
move $s2,$a2 # keep copy of spare tower
move $a0,$s0 # step 1:
move $a1,$s2 # destination = spare tower
move $a2,$s1
sub $a3,$a3,1 # move n-1 rings
jal moveStack
move $a0,$s0 # step 2:
move $a1,$s1
jal moveRing # move a ring to destination
move $a0,$s2 # step 3:
move $a1,$s1
move $a2,$s0 # source = spare
jal moveStack
j end
moveOne:
jal moveRing # Move one ring only
end: lw $a0,0($sp) # restore registers
lw $a1,4($sp)
lw $a2,8($sp)
lw $a3,12($sp)
lw $s0,16($sp)
lw $s1,20($sp)
lw $s2,24($sp)
lw $ra,28($sp)
add $sp,$sp,32
jr $ra
#------------------------------------------------
# moveRing - move one ring from source to dest
# a0 - source
# a1 - dest
# t0 - holds the value removed
#------------------------------------------------
moveRing:
sub $sp,$sp,12 # save registers on stack
sw $a0,0($sp)
sw $a1,4($sp)
sw $ra,8($sp)
jal PrintTowers # print out state of towers
finds: sub $a0,$a0,4 # get the top ring
lw $t0,($a0)
beqz $t0,founds
j finds # find source
founds: add $a0,$a0,4
lw $t0,($a0) # t0 holds the value removed
sw $0,($a0) # set place to zero
findd: sub $a1,$a1,4 # find destination
lw $t1,($a1)
beqz $t1,foundd
j findd
foundd: sw $t0,($a1) # destination found
lw $a0,0($sp) # restore registers
lw $a1,4($sp)
lw $ra,8($sp)
add $sp,$sp,12
jr $ra
#------------------------------------------------
# PrintTowers - print out state of towers
# s0 - number of rings
# s1 - tower1
# s2 - tower2
# s3 - tower3
#------------------------------------------------
PrintTowers:
sub $sp,$sp,28 # save registers on stack
sw $v0,0($sp)
sw $a0,4($sp)
sw $s0,8($sp)
sw $s1,12($sp)
sw $s2,16($sp)
sw $s3,20($sp)
sw $ra,24($sp)
la $s1,tower1 # set up the registers
la $s2,tower2 # from the data segment
la $s3,tower3
lw $s0,numRings
mul $s0,$s0,4 # each word four bytes
sub $s1,$s1,$s0 # get stacks ready
sub $s2,$s2,$s0
sub $s3,$s3,$s0
Loop: beqz $s0,exit # if at level -n done
la $a0,Blanks
li $v0,4 # system call to print
syscall # out a string
lw $a0,($s1) # read number on stack 1
jal printOne # print blank or ring
lw $a0,($s2) # read number on stack 2
jal printOne # print blank or ring
lw $a0,($s3) # read number on stack 3
jal printOne # print blank or ring
la $a0,endl # end line
li $v0,4 # system call to print
syscall # out a string
sub $s0,$s0,4 # move up to next level
add $s1,$s1,4
add $s2,$s2,4
add $s3,$s3,4
j Loop # repeat until $s0=0
exit: la $a0,Base # print Tower names and lines
li $v0,4 # system call to print
syscall # out a string
lw $v0,0($sp) # restore registers
lw $a0,4($sp)
lw $s0,8($sp)
lw $s1,12($sp)
lw $s2,16($sp)
lw $s3,20($sp)
lw $ra,24($sp)
add $sp,$sp,28
jr $ra
#------------------------------------------------
# printOne - print blank or ring number
# a0 - holds ring number or 0
# v0 - parameter for system call
#------------------------------------------------
printOne:
sub $sp,$sp,12 # save registers on stack
sw $a0,0($sp)
sw $v0,4($sp)
sw $ra,8($sp)
bnez $a0,ring # if not zero then print it
la $a0,Blank
li $v0,4 # system call to print
syscall # out a string
j spaces
ring: li $v0,1 # print number
syscall
spaces: la $a0,Blanks # space output out
li $v0,4 # system call to print
syscall # out a string
lw $a0,0($sp) # restore registers
lw $v0,4($sp)
lw $ra,8($sp)
add $sp,$sp,12
jr $ra
#################################################
# #
# data segment #
# #
#################################################
.data
Blanks: .asciiz " "
Blank: .asciiz " "
endl: .asciiz "\n"
Base: .ascii " ____ ____ ____\n"
.asciiz " T1 T2 T3\n\n\n"
.align 2
notused:
.word 0,0,0,0,0,0,0,1,2,3
tower1: .word 0,0,0,0,0,0,0,0,0,0
tower2: .word 0,0,0,0,0,0,0,0,0,0
tower3: .word 0
numRings:
.word 3
##
## end of file hanoi.a
__________________
Công ty TNHH Thương mại và Giao nhận R&P store.hn@rpc.vn - store.hcm@rpc.vn Học PIC như thế nào? |
|
|
|
|
|
#3 |
|
Đệ tử 1 túi
Tham gia ngày: Jan 2007
Bài gửi: 19
: |
Cũng đang muốn nghiên cứu con này 1 chút. Không biết mua số lượng nhỏ từ 3->5 con ở công ty của bác có được ko nhỉ? Giá của con pic32mx360f512l cỡ bao nhiêu nhỉ?
|
|
|
|
|
|
#4 | |
|
PIC Bang chủ
|
Trích:
Chúc vui
__________________
Công ty TNHH Thương mại và Giao nhận R&P store.hn@rpc.vn - store.hcm@rpc.vn Học PIC như thế nào? |
|
|
|
|
|
|
#5 |
|
Đệ tử 9 túi
|
Thêm tài liệu khuyến cáo của bọn Microchip tại site này: http://www.microchip.com/stellent/id...GE&nodeId=2604
Download: Programming 32-bit Microcontrollers in C: Exploring the PIC32 by Lucio Di Jasio Phần examples có thể down tại trang chủ của tác giả: http://www.exploringpic32.com/index.html Chúc mọi người thành công. |
|
|
|
|
|
#6 |
|
Nhập môn đệ tử
Tham gia ngày: Sep 2010
Bài gửi: 1
: |
Cũng đang muốn nghiên cứu con này 1 chút
|
|
|
|
|
|
#7 |
|
Nhập môn đệ tử
Tham gia ngày: May 2010
Bài gửi: 1
: |
em muon tim tập lệnh PIC 16F877a anh nao co cho em xin voi nhe cam on cac anh,nếu co vui lòng gửi vào Tongtrungthanhyh39@gmail.com cho em nhe.thanhk you
|
|
|
|
|
|
#8 |
|
Đệ tử 6 túi
Tham gia ngày: Jan 2007
Bài gửi: 127
: |
Khi biên dịch code bạn sẻ nạp trực tiếp code vào flash. nếu bạn muốn nạp website qua mạng erthernet bạn phải cấu hình địa chỉ mạng và định địa chỉ nhớ để load website vào. nếu muốn biết rỏ hơn và thực hành thực tế. bạn có thể tham gia đăng lớp học pic về chuyên đề giao tiếp ethernet tại trung tâm điện điện tử k27/5 quang trung. nếu bạn ở Đà Nẵng.
chúc vui. |
|
|
|
![]() |
|
|