1 / 12

ECE 447: Lecture 3

ECE 447: Lecture 3. Microcontroller Programming in C. ECE 447: Class Exercise. Write a program in C that transfers 512 bytes of data starting at address 6000H to the block of memory starting at address 8000H. $0000-$01FF 512 bytes RAM. $0000. $1000. $ 2 000. $1000-$103F

Télécharger la présentation

ECE 447: Lecture 3

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. ECE 447: Lecture 3 Microcontroller Programming in C

  2. ECE 447: Class Exercise Write a program in C that transfers 512 bytes of data starting at address 6000H to the block of memory starting at address 8000H.

  3. $0000-$01FF 512 bytes RAM $0000 $1000 $2000 $1000-$103F 64 bytes I/O registers $2000-$B5FF 37.5 kbytes $B600 $B600-$B7FF 512 bytes EEPROM $D000 $D000-$FFFF 12 kbytes ROM $FFFF Expanded bus mode ECE 447: 68HC11E9 Memory Map External RAM External RAM recommended for use recommended for use External RAM

  4. $0000-$01FF 512 bytes RAM $0000 $1000 $6000 $2000 $1000-$103F 64 bytes I/O registers $6000-$B5FF 21.5 kbytes $2000-$5FFF 16 kbytes $B600 $B600-$B7FF 512 bytes EEPROM $D000 $FFFF Expanded bus mode ECE 447: Memory Map: Linker file Program area - text External RAM Data area – data External RAM

  5. Text editor Assembly source C source .c .s Cross-compiler m6811-elf-gcc Cross-assembler m6811-elf-as Object listing .lst Relocatable object .o Relocatable object .o libraries Linker m6811-elf-ld (m6811-elf-gcc) {lib_name}.a Linker command file User libraries memory.x {lib_name}.a Non-relocatable executable program (a.out) ECE 447: Software Cycle

  6. Non-relocatable executable image a.out Downloadable file converter : m6811-elf-objcopy Downloadable file a.s19 ECE 447: Software Cycle

  7. ECE 447: Class Exercise 2 Write a program in C that continuously transfers data from PORT E to PORT C of MC68HC11.

  8. RAM CPU ROM EEPROM A/D SPI TIMER SCI 8 (4) 8 4 2 PORT A PORT B PORT C PORT D PORT E 3 3 2 8 8 6 8 (4) ECE 447: Organization of MC68HC11

  9. ECE 447: Class Exercise 3 Write a program in C that continuously scanspin PE5of PORT E of MC68H11. Whenevera falling edge is detected at PE5, the microcontroller shouldclear the pin PC4,and toggle pin PC2 of MC68HC11.

  10. ECE 447: Setting and Clearing a bit Clearing a bit Setting a bit #define BIT3 0x04 unsigned char c = 5; void set_bit3(void) { c |= BIT3; } #define BIT3 0x04 unsigned char c = 5; void clear_bit3(void) { c &= ~BIT3; }

  11. ECE 447: Toggling a bit #define BIT3 0x04 unsigned char c = 5; void toggle_bit3(void) { c ^= BIT3; }

  12. ECE 447: Setting a bit at a given memory location #define BIT3 0x04 #define ADDR 0x1005 void set_bit3(void) { unsigned char *ptr; ptr = (unsigned char *) ADDR; *ptr |= BIT3; }

More Related