1 / 8

Actividad Práctica sobre MC9S08SH8

Actividad Práctica sobre MC9S08SH8. Utilizando EBDM y CodeWarrior 10.1. Pantalla Inicial. for(k=0 ; k<10000 ; k++) { suma=suma+k; } #define LIMITE 10000 for(k=0 ; k< LIMITE ; k++) { suma=suma+k; }. #define LIMITE 5 for(k=0 ; k< LIMITE ; k++) { suma=suma+k; }

brie
Télécharger la présentation

Actividad Práctica sobre MC9S08SH8

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. Actividad Práctica sobre MC9S08SH8 Utilizando EBDM y CodeWarrior 10.1

  2. Pantalla Inicial Introducción a la Programación en C sobre uC 9S08 de Freescale -SASE 2013-

  3. for(k=0 ; k<10000 ; k++) { suma=suma+k; } #define LIMITE 10000 for(k=0 ; k< LIMITE ; k++) { suma=suma+k; } #define LIMITE 5 for(k=0 ; k< LIMITE ; k++) { suma=suma+k; } for(k=0 ; k< LIMITE ; k++) { if(k%2==0) { suma=suma+k; } suma=suma+k; } for(k=0 ; k< LIMITE ; k++) { if(k%2==1) { suma=suma+k; } } Macros #define Introducción a la Programación en C sobre uC 9S08 de Freescale -SASE 2013-

  4. Como acceder a los puertos • Los registros de los periféricos están mapeados en memoria. • No es fácil acordarse de las direcciones • Queremos un sistema mejor. • Nos convendría que los registros se vieran como variables. • CW nos da esto resuelto, usando macros en el archivo mc9s08sh8.h Introducción a la Programación en C sobre uC 9S08 de Freescale -SASE 2013-

  5. archivo mc9s08sh8.h externvolatile PTBDSTR _PTBD @0x00000002; #define PTBD _PTBD.Byte #define PTBD_PTBD0 _PTBD.Bits.PTBD0 #define PTBD_PTBD1 _PTBD.Bits.PTBD1 #define PTBD_PTBD2 _PTBD.Bits.PTBD2 #define PTBD_PTBD3 _PTBD.Bits.PTBD3 #define PTBD_PTBD4 _PTBD.Bits.PTBD4 #define PTBD_PTBD5 _PTBD.Bits.PTBD5 #define PTBD_PTBD6 _PTBD.Bits.PTBD6 #define PTBD_PTBD7 _PTBD.Bits.PTBD7 Introducción a la Programación en C sobre uC 9S08 de Freescale -SASE 2013-

  6. Placa de Prueba Introducción a la Programación en C sobre uC 9S08 de Freescale -SASE 2013-

  7. R Placa de LEDS b0 b1 b2 b3 b4 b7 b5 b6 R R R R R R R G R B B G Y Y R Introducción a la Programación en C sobre uC 9S08 de Freescale -SASE 2013-

  8. Encendido / Apagado de los leds conectados al puerto B: Encendido del bit 0 PTBD_PTBD0=1; Apagado bit 0 PTBD_PTBD0=1; Si quiero trabajar con todo el puerto junto, por ejemplo todos los bits pares. PTBD=0x55 (01010101); si quiero invertirlos ( bits impares) PTBD=~PTBD; o bien PTBD=PTBD^ 0xFF; Introducción a la Programación en C sobre uC 9S08 de Freescale -SASE 2013-

More Related