6272 Embedded Controller I/Oktober 2016
From Teknologisk videncenter
Contents
C
- ctutor.pdf
- C programming (Local articles)
- Const and volatile type qualifiers
- ASC-II tegnsættet
MSP430
- MSP430
- MSP430 Introduktion (Loads PDF)
Opgaver
MSP430/MSP430G2 Serial 1 project
Få stdio bibliotek til at virke
UART_poll.c
Indsæt følgende nederst i UART_poll.c
int putchar( int charout ) {
cout( (char) charout );
return(charout);
}
int getchar( void ) {
int charin;
charin = (int) cin();
if ( (charin == 0x0d ) || (charin == 0x0a) ) { // CR or LF
putchar( 0x0d ); // Output CR+LF
putchar( 0x0a );
return( 0x0a ); // Return LF
} else { // Else other character
putchar( charin );
return( charin );
}
}
UART_poll.h
Indsæt følgende linier nederst i UART_poll.h
extern int putchar( int charout );
extern int getchar( void );
Main.c
Indsæt følgende include sætning øverst i main.c
#include <stdio.h>
Lysdioder port definitioner
#define SMALL_BOARD // Using MSP430G2553
//#define BIG_BOARD // Using MSP430F5529
#ifdef SMALL_BOARD
unsigned char volatile * const PORT1SEL = (unsigned char *) 0x0026;
unsigned char volatile * const PORT1SEL2 = (unsigned char *) 0x0041;
unsigned char volatile * const PORT1IN = (unsigned char *) 0x0020;
unsigned char volatile * const PORT1OUT = (unsigned char *) 0x0021;
unsigned char volatile * const PORT1DIR = (unsigned char *) 0x0022;
#endif
#ifdef BIG_BOARD
unsigned char volatile * const PORT1SEL = (unsigned char *) 0x020a;
unsigned char volatile * const PORT1IN = (unsigned char *) 0x0200;
unsigned char volatile * const PORT1OUT = (unsigned char *) 0x0202;
unsigned char volatile * const PORT1DIR = (unsigned char *) 0x0204;
unsigned char volatile * const PORT4SEL = (unsigned char *) 0x022b;
unsigned char volatile * const PORT4IN = (unsigned char *) 0x0221;
unsigned char volatile * const PORT4OUT = (unsigned char *) 0x0223;
unsigned char volatile * const PORT4DIR = (unsigned char *) 0x0225;
#endif