1 / 19

Memory Organization II

Memory Organization II. Microprocessor and Interfacing 261214. PIC Flash Memory Segments. 12. 10. 0. 2K. 2K. 2K. 2K. PIC’s RAM Banking. Instruction Format. f = 7 bit Maximum memory = 2^7 = 128 Bytes. PIC 16F877 has 512 bytes of RAM: How do we access all of it?. 7. 0.

rashad
Télécharger la présentation

Memory Organization II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Memory Organization II Microprocessor and Interfacing261214

  2. PIC Flash Memory Segments 12 10 0 2K 2K 2K 2K

  3. PIC’s RAM Banking

  4. Instruction Format

  5. f = 7 bit Maximum memory = 2^7 = 128 Bytes

  6. PIC 16F877 has 512 bytes of RAM: How do we access all of it? 7 0 STATUS (F# 0x03) Bit 5-6 (RP0,RP1) in STATUS are used for RAM Page selection Total Memory becomes 2^9 = 512 Bytes

  7. 7 0 Creating a 9 bit RAM address 13 7 6 0 OPCODE f (File#) STATUS 8 6 0 9 Bit RAM Address

  8. This code should now make sense

  9. RAM location First 32 bytes of every page are reserved. Except on pages 3 and 4 User RAM space. Last 16 Bytes are mirrored

  10. The big picture: where the bits are 6 5 7 0 4 3 7 0 Bit 5-6 (RP0,RP1) in STATUS are used for RAM Page selection Bit 3-4 in PCLATH are usedfor memory access

  11. 2. เร่ง Memory Operations ด้วยIndirect Addressing

  12. ทำไมต้องมี Indirect Addressing? สมมุติว่าเรามี Array ในภาษา C ดังนี้ int value[8]; หลังจากที่ใช้งานมันไปสักพักเราอยาก Clear ค่าใน array ทั้งหมดมีค่าเป็น 0 Code จะเป็นอย่างไรถ้าเราไม่สามารถใช้ตัวแปรอ้างตำแหน่งใน Array เช่นห้ามใช้ value[i] = 0;

  13. With indirect addressing For (i=0 ; i<8 ; i++) { value[i] = 0; } Without indirect addressing Value[0] = 0; Value[1] = 0; Value[2] = 0; Value[3] = 0; Value[4] = 0; Value[5] = 0; Value[6] = 0; Value[7] = 0;

  14. Opcode File PIC’s Indirect Addressing

  15. 7 0 Creating a 9 bit indirect RAM address 7 0 FSR (File #4) 8-bit address STATUS 8 7 0 9 Bit RAM Address

  16. Example: clear RAM locations 0x20 – 0x27 (8 Bytes) 0x20 = 0b0010 0000 0x27 = 0b0010 0111

  17. The big picture: where the bits are 7 6 5 0 Bit 5-6 (RP0,RP1) in STATUS are used for RAM Page selection 4 3 7 0 Bit 7 (IRP) in STATUS is used for indirect Addressing Bit 3-4 in PCLATH are usedfor memory access

  18. Indirect Addressing Ex Find the sum of values in RAM address 0x22-0x25 and store at address 0x21 ; 0x21 = sum result variable clrf 0x21 ; 0x22 - 0x25 = input numbers to be summed movlw 4 movwf 0x22 movlw 3 movwf 0x23 movlw 2 movwf 0x24 movlw 1 movwf 0x25 End Result: Sum = Value1+Value2+Value3+Value4

More Related