kavinyang
Joined: 17 Apr 2008 Posts: 4 Location: USA
|
Need help with ISR |
Posted: Thu May 29, 2008 10:36 pm |
|
|
Hello fellow, engineer and genius, i'm working on this code for my GSM to read all the character that the GSM modem telit respond back to the PIC and had it display on the LCD but i'm not getting anything please advise me on doing this project. Thankyou so much, this is my code here, please feel free to comment me about my error, and mistake; i'm still a noobie to CCS for PIC, so please guide me.
thankyou,
this is my code:
Code: |
#include "string.h"
#fuses HS, NOWDT, NOPROTECT, NOLVP
#use delay(clock = 4mhz)
#use rs232(baud=4800, bits=8, parity=N, stop=1, xmit=PIN_C6, rcv=PIN_C7, stream=GSM)
void out_lcd_string(char *string);
char initialize[] = "Initialize....";
void clear_lcd(void);
void lcdcmd(int value1);
void lcddata(char value);
void poweron(void);
void display(char *x);
char char_rcvd;
void readindex(void);
void ledtest(void);
byte data[95];
int t = 0;
#int_rda
void serial_isr()
{
int i= 0;
char_rcvd = fgetc(GSM);
while (i != 10)
{
char_rcvd = fgetc(GSM);
data[i]=char_rcvd;
t=1;
output_high(PIN_B7);
i++;
}
data[i] = 0; // return new line shows that all character has been collected
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
enable_interrupts(global);
enable_interrupts(int_rda);
//setup_oscillator(False);
output_low(PIN_B7);
output_low(PIN_B6);
output_low(PIN_B5); // goes low for GSM modem
poweron();
delay_ms(200);
delay_ms(500);
lcdcmd(0x38); // init LCD 2 lines 5x7 matrix
delay_ms(200);
lcdcmd(0x0e); // display on, cursor on
delay_ms(200);
lcdcmd(0x01); // clear LCD
delay_ms(200);
lcdcmd(0x80); //shift cursor
delay_ms(200);
display(initialize); //display initialize on LCD
delay_ms(300);
clear_lcd();
delay_ms(300);
delay_ms(200);
lcdcmd(0x0f); // display on, cursor on
delay_ms(200);
readindex();
delay_ms(200);
out_lcd_string(data);
delay_ms(200);
}
void lcdcmd(int value1)
{
output_low(PIN_A1); //rs low
output_low(PIN_A2); //enable
output_d(value1) ; //put the value on the pins
output_high(PIN_A2); //strobe the enable pins H-L pulse
delay_ms(15);
output_low(PIN_A2); //enable
}
void lcddata(char value)
{
output_d(value); //put the value on the pins
output_high(PIN_A1); //rs high
output_high(PIN_A2); // enable pins H-L pulse
delay_ms(15);
output_low(PIN_A2); //enable pins
}
void display(char *x) //this function will display a string of character
{
int i = 0;
for(i = 0; i<strlen(x); i++)
lcddata(x[i]);
}
void clear_lcd(void)
{
output_low(PIN_A2); //enable bit
output_low(PIN_A1); // Rs= 0
output_d(0x01); //clear display
output_high(PIN_A2); // H-L pulse
delay_ms(1);
output_low(PIN_A2); // H-L pulse
}
void poweron(void)
{
output_low(PIN_B5);
output_high(PIN_B5);
delay_ms(2000);
output_low(PIN_B5);
}
void out_lcd_string(char *string) //this function will display all string of SMS from GSM
{
unsigned int i;
for(i =0; i<strlen(string); i++)
{
output_d((int)string[i]);
delay_ms(1);
output_high(PIN_A2); //enable
output_low(PIN_A1); //low disable
delay_ms(1);
output_low(PIN_A2);
delay_ms(1);
}
}
void readindex(void)
{
//while(1)
{
delay_ms(1000);
fprintf(GSM, "AT+CMGF = 1\r\n"); //set to GSM to text mode
delay_ms(3000);
enable_interrupts(int_rda);
fprintf(GSM, "AT+CMGR = 1\r\n"); //read SMS at location inedex one
while(t!=1){} // wait til interrupt
disable_interrupts(int_rda);
delay_ms(100);
t = 0;
output_high(PIN_B6);
out_lcd_string(data); //send SMS string to LCD
}
}
|
help me please cause time is running low on me _________________ PHIA YANG |
|