48 lines
1.7 KiB
C
48 lines
1.7 KiB
C
/* *********************************************** *
|
|
* main.c *
|
|
* Simple 68HC08JK1 Test Program *
|
|
* ----------------------------------------------- *
|
|
* Created on: 10.08.2015 *
|
|
* Author: q242695 *
|
|
* *********************************************** */
|
|
/* *********************************************** *
|
|
* Pin assignment:
|
|
* ---------------
|
|
* +--\/--+
|
|
* VPP /IRQ1 1|° |20 /RST
|
|
* VSS 2| |19 PTD4
|
|
* OSC OSC1 3| |18 PTD5
|
|
* OSC2 4| |17 PTD2
|
|
* VDD 5| |16 PTD3
|
|
* PTB7 6| |15 PTB0 RXTX
|
|
* PTB6 7| |14 PTB1 MOD0 (1)
|
|
* PTB5 8| |13 PTB2 MOD1 (0)
|
|
* PTD7 9| |12 PTB3 DIV4 (1)
|
|
* PTD6 10| |11 PTB4
|
|
* +------+
|
|
* ************************************************ */
|
|
|
|
#include "mc68hc908jkjl.h"
|
|
#define Switch PTB5 // Pull Down
|
|
unsigned char tmp;
|
|
|
|
void main (void) {
|
|
CONFIG1 |= 0x01; // Disables COP
|
|
DDRB = 0xF0; // Configures port B[7..4] as output
|
|
DDRD = 0xF0; // Configures port D[7..4] as output
|
|
ADSCR = 0x29; // Enables ADC channel 9
|
|
ADCLK = 0x40; // ADC input clock / 4
|
|
|
|
for(;;){ // Forever
|
|
while(!(ADSCR & 0x80)) ; // Waits for ADC end of conversion
|
|
tmp = ADR; // Saves the ADC value on a temporary data
|
|
PTD = tmp; // Writes the ADC value on port D[7..4]
|
|
PTB = tmp << 4; // Writes the ADC value on port B[7..4]
|
|
if(!Switch){
|
|
PTD = 0xF0;
|
|
PTB = 0xF0;
|
|
}
|
|
}
|
|
}
|
|
|