#include "MK10D7.H"
#define red_led_loc (1<<1)
#define red2_led_loc (1<<0)
#define red_led_on PTB->PSOR =red_led_loc
#define red_led_off PTB->PCOR =red_led_loc
#define red2_led_on PTB->PSOR =red2_led_loc
#define red2_led_off PTB->PCOR =red2_led_loc
void SystemInit(void){
}
void Delay(int Ticks){
int i;
for(i=0;i<Ticks;i++)
{
}
}
int i ;
int main (void)
{
SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK;
SIM->SCGC6 |= SIM_SCGC6_PIT_MASK ;
///////////////////////////////////////////////////////////////////
PORTB->PCR[1] = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;
PORTB->PCR[0] = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;
PTB->PDDR |= red_led_loc | red2_led_loc ;
PIT->MCR = PIT_MCR_FRZ_MASK ;
////////////////////
red_led_off;
red2_led_off;
NVIC_EnableIRQ( PIT1_IRQn ); //enable interrupts timer1
PIT -> CHANNEL[1].LDVAL = 0x0003E7FF; // Timer 1 =5 msn
PIT -> CHANNEL[1].TCTRL = PIT_TCTRL_TEN_MASK | PIT_TCTRL_TIE_MASK; //timer interrupt enable , timer enable
while(1){
}
}
void PIT1_IRQHandler(void){
i++;
PIT ->CHANNEL[1].TFLG |= PIT_TFLG_TIF_MASK;
PIT ->CHANNEL[1].TCTRL = PIT_TCTRL_TEN_SHIFT;
PIT -> CHANNEL[1].LDVAL = 0x0003E7FF;
PIT -> CHANNEL[1].TCTRL |= PIT_TCTRL_TEN_MASK | PIT_TCTRL_TIE_MASK;
if (!(i%100) ){
red2_led_on;
}
if (!(i%200) ){
red_led_on;
}
if (!(i%400)){
red_led_off;
red2_led_off;
}
}
This code is working on my prototype board right now after i download it to the chip with my Jlink8 . But when i cut the power and power it again , it does not start . Also you can see attached photos for my rom settings on keil...
Salih...