30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.2.7 Overflow and Saturation Handling<br />

The DSP Library performs most computationsusing 9.31 saturation, but must<br />

store the<br />

output of the function in 1.15 format. If during the course of operation the<br />

accumulator<br />

in use saturates (goes above 0x7F FFFFFFFF or below 0x80 0000 0000), the<br />

corresponding saturation bit (SA or SB) in the Statusregister will be set. This bit<br />

will stay set<br />

until it is cleared. This allows you to inspect SA or SB after the function<br />

executes and<br />

to determine if action should be taken to scale the input data to the function.<br />

Similarly, if a computation performed with the accumulator results in an<br />

overflow (the<br />

accumulator goes above 0x00 7FFF FFFF or below 0xFF 8000 0000), the<br />

corresponding overflow bit (OA or OB) in the Status register will be set. Unlike<br />

the SA and SB status bits, OA and OB will not stay set until theyare cleared.<br />

These bits are updated each<br />

time an operation using accumulator is executed. If exceeding this specified<br />

range<br />

marks an important event, you are advised to enable the Accumulator Overflow<br />

Trap<br />

via the OVATE and OVBTE bits in the INTCON1 register. This will have the<br />

effect of<br />

generating an Arithmetic Error Trap as soon asthe Overflow condition occurs,<br />

and you<br />

may then take the required action.<br />

2.2.8 Integrating with Interrupts and an RTOS<br />

The DSP Library may easily be integrated into an application which utilizes<br />

interrupts<br />

or an RTOS, yet certain guidelines must be followed. To minimize execution<br />

time, the<br />

DSP Library utilizes DOloops, REPEATloops, modulo addressing and bitreversed<br />

addressing. Each of these components is a finite hardware resource on the<br />

dsPIC30F<br />

DSC, and the background code must consider the use of each resource when<br />

disrupting execution of a DSP Library function.<br />

When integrating with the DSP Library, you must examine the Function Profile<br />

of each<br />

function description to determine which resources are used. If a library function<br />

will be<br />

interrupted, it is your responsibility to save and restore the contents of all<br />

registers used<br />

by the function, including the state of the DO, REPEATand special addressing<br />

hardware. Naturally this also includes saving and restoring the contents of the<br />

CORCON<br />

and Status registers.<br />

2.2.9 Rebuilding the DSP Library<br />

dsPIC30F<br />

DSC, và mã nền phải xem xét việc sử dụng tài nguyên mỗi khi<br />

làm gián đoạn thực hiện một chức năng DSP Thư viện.<br />

Khi kết hợp với Thư viện DSP, bạn phải kiểm tra các chức năng của từng hồ sơ<br />

Mô tả chức năng để xác định các nguồn lực được sử dụng. Nếu một chức năng<br />

thư viện sẽ<br />

bị gián đoạn, bạn có trách nhiệm lưu và khôi phục lại nội dung của tất cả các<br />

đăng ký sử dụng<br />

bởi các chức năng, bao gồm cả trạng thái của DO, REPEATand đặc biệt phần<br />

cứng giải quyết. Đương nhiên điều này cũng bao gồm lưu trữ và khôi phục lại<br />

nội dung của CORCON<br />

và tình trạng đăng ký.<br />

2.2.9 Xây dựng lại thư viện DSP<br />

Một tập tin thực thi có tên makedsplib.batis cung cấp để xây dựng lại thư viện<br />

DSP. Các<br />

Trình biên dịch MPLAB C30 là cần thiết để xây dựng lại các thư viện DSP, và<br />

hàng loạt tập tin giả<br />

trình biên dịch được cài đặt trong thư mục mặc định, c: \ pic30_tools. Nếu công<br />

cụ ngôn ngữ của bạn được cài đặt trong một thư mục khác, bạn phải thay đổi<br />

các thư mục trong<br />

tập tin thực thi để phù hợp với vị trí của công cụ ngôn ngữ của bạn.<br />

DSP Thư viện<br />

2004 Microchip Technology Inc DS51456B trang 13<br />

2.3 chức năng VECTOR<br />

Phần này trình bày các khái niệm về một vector phân đoạn, như xem xét bởi<br />

DSP<br />

Thư viện, và mô tả các chức năng cá nhân đó thực hiện các hoạt động vector.<br />

2.3.1 Fractional Vector hoạt động<br />

Một vector phân đoạn là một tập hợp các giá trị số, các yếu tố vector, phân bổ<br />

liên tục kế nhau trong bộ nhớ, với người đầu tiên elementAt địa chỉ bộ nhớ thấp<br />

nhất. Một từ<br />

bộ nhớ (hai byte) được sử dụng để lưu trữ các giá trị của mỗi phần tử, và số<br />

lượng này<br />

phải được hiểu như là một phân số đại diện trong các định dạng dữ liệu 1.15.<br />

Một con trỏ giải quyết các yếu tố đầu tiên của vector được sử dụng như một xử<br />

lý cung cấp<br />

tiếp cận với mỗi giá trị vector. Địa chỉ của phần tử đầu tiên được gọi là<br />

địa chỉ cơ sở của vector. Bởi vì mỗi phần tử của vector là 16 bit, các cơ sở<br />

địa chỉ mustbe liên kết đến một địa chỉ mặc.<br />

Một thỏa thuận chiều của một vector chứa để lưu trữ bộ nhớ<br />

mô hình của thiết bị, do đó yếu tố thứ n của một vector N phần tử có thể được<br />

truy cập<br />

từ địa chỉ cơ sở BA của vector như:<br />

BA + 2 (n-1), cho 1 ≤n ≤N.<br />

Các hệ số 2 được sử dụng vì các byte khả năng của dsPIC30F giải quyết<br />

thiết bị.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!