Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

please help in debugging the C program

$
0
0

char input[20]; volatile bit rx_event; void interrupt() { if (PIR1.RCIF) { UART1_Read_Text(input, "\r", 20); rx_event=1; }

void main() {

short Start_up=0; short i; OSCCON.b6=1; OSCCON.b5=1; OSCCON.b4=0; OSCCON.b1=1;

UART1_Init(38400); ANSELH.ANS11 =0; IOCB.IOCB7=0; TRISB.TRISB6=0; TRISB.TRISB7=1;

Soft_UART_Init(&PORTC, 7, 6, 38400, 0); INTCON.PEIE = 1; //peripheral interrupt enable PIE1.RCIE = 1; //Receive char Interrupt Enable bit PIR1.RCIF = 0; //Receive char Interrupt flag- reset to 0 INTCON.GIE = 1; //global interrupt enable rx_event=0; //initialize rx_evnet to = 0

delay_ms(1000); //wait one sec for the stamp to stabilize if(Start_up==0){ //when the program firsts starts it will for(I = 1; I<=3;i++){ //flash on / off the stamps led uart1_write_text("L0"); //"L0" = led's off uart1_write(13); //<cr> delay_ms(1000); //wait one sec uart1_write_text("L1"); //"L1" = led's on uart1_write(13); //<cr> delay_ms(1000); //wait one sec } Start_up = 1; //by setting Start_up to 1, we stop the leds from flashing on/off }

delay_ms(1000); //wait one sec for the stamp to stabilize after the led flashing uart1_write_text("c"); //the command "c" will tell the stamp to take continues readings uart1_write(13); //<cr> delay_ms(500); while(1){ short len=0; if(rx_event){ rx_event=0; len = strlen(input); for(i=0;i<len;i++){ Soft_UART_Write(input[i]); } Soft_UART_Write(13); } } }


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>