char GSM_Buffer[37];
char buffer[36];
//char SMS[30];
//char SMS_Index[4];
//char SMS[30];
//char SMS_Index[4];
if you form the message in ram like reading temperature and converting it to string and using it as sms then you need sms[] variable and in your Send_SMS() function *s8 is char that is char*s8So far the longest SMS is 58.
I think I need to include all letters and "space, but no "\". Am I right ?
Can you clarify these for me ?
const char [59]
char [59]
1.Yes1. If the message does not change I have to use "const char" right?
2. I believe I would need "char" if I need to read the SMS and send it, right ?
Yes.Would I need to disable TMR0 and TMR1 during a SMS is being sent ?
If code compiles without them then you don't need them.What I mean is do I need them ?
Code compiles without them.
void Send_SMS(char *s1, char *s2, const char *s3, const char *s4, const char *s5, const char *s6, const char *s7, char *s8, unsigned int *idx, char *gsmAttempt, char clr) {
asm clrwdt
while(strstr(s1, CopyConst2Ram(s2, s3)) == 0) {
asm clrwdt
GSM_Send_Const_Command(s1, s2, s3, s5, idx, gsmAttempt, 1);
GSM_Send_Const_Command(s1, s2, s3, s6, idx, gsmAttempt, 1);
GSM_Send_Const_Command(s1, s2, s4, s7, idx, gsmAttempt, 1);
UART1_Write_Text(s8);
Delay_ms(500);
UART1_Write(0x1A);
DelayXSec(6);
}
memset(gsmBuffer, '\0', sizeof(gsmBuffer));
(*idx) = 0;
asm clrwdt
void Send_SMS(char *s1, char *s2, const char *s3, const char *s4, const char *s5, const char *s6, const char *s7, char *s8, unsigned int *idx, char *gsmAttempt, char clr)
while(strstr(s1, CopyConst2Ram(s2, s3)) == 0)
void main(){
OSCCON = 0x77; // 8MHz Internal Osc.
ANSEL = 0x03; // RA0 & RA1 as Analog Rest as Digital IO.
ANSELH = 0x00; // Rest as Digital IO.
CM1CON0 = 0x07; // Disable Comparator 1.
CM2CON0 = 0x07; // Disable Comparator 2.
PORTA = 0; // Clear PORT A.
PORTB = 0; // Clear PORT B.
PORTC = 0; // Clear PORT C.
PORTD = 0; // Clear PORT D.
PORTE = 0; // Clear PORT E.
TRISA = 0xFF; // PORT A as Input.
TRISB = 0x00; // PORT B as Output.
TRISC = 0xB8; // "b10111000".
PORTDimg = 0x2F; // PORT D Shadow, Identical to TRISD.
TRISD = 0x2F; // RD <0 - 3 & 5> as Input, Rest as Output.
TRISE = 0xFF; // PORT E as Input.
ADC_Init(); // Innitiate ADC.
VCFG0_bit = 1; // Externel Vref +.
VCFG1_bit = 0; // Internal Vref - as GND.
Lcd_Init(); // Innitiate LCD.
Lcd_Cmd(_LCD_CLEAR); // Clear LCD.
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor OFF.
Delay_ms(100); // Wait to Stabilize.
UART1_Init(9600); // Initialize UART module at 9600 baud.
Delay_ms(100); // Wait for UART module to stabilize.
//------- Clear and Set up IRQ and Fire up the Timers --------------------------
OPTION_REG = 0x81; // No pullups, Timer 0 at Prescaler 4.
INTCON = 0; // Disable All Interrupts First.
PIE1 = 0; // Disable All Peripheral Interrupts.
PIE2 = 0; // Disable All Peripheral Interrupts.
INTCON.T0IE = 1; // Enable the Timer0 Interrupt.
INTCON.T0IF = 0; // Clear Timer 0 Register Overflow Flag.
TMR0 = TMR0set; // Load Timer 0 with Preset.
T1CON = 0x30; // No gate, Int Tcyc/8, TMR1 Stopped.
TMR1H = TMR1L = 0; // Timer counts up to CCP value.
CCPR1 = 625; // 1usTcyc * 8 Prescale * 625 = 5msec.
CCP1CON = 0x0B; // NO Hardware PWM.
TMR1IF_bit = 0; // PIR1 reg, Clear the TMR1 Overflow IRQ.
CCP1IF_bit = 0; // Clear TMR1 IRQ flag bit.
T1CON.TMR1ON = 1; // Start TIMER 1.
TMR1IE_bit = 1; // Enable the Timer1 overflow Interrupt.
RCIF_bit = 0; // Clear Rx Interrupt Flag (GSM)
PIE1.RCIE = 1; // Enable Rx Interrupt (GSM)
CCP1IE_bit = 1; // Enable the CCP1 Interrupt.
INTCON.GIE = 1; // Global Interrupt Enabled.
void main() {
OSCCON = 0x33;
//OSCCON2 = 0x07;
ANSELA = 0x03;
ANSELB = 0x00;
ANSELC = 0x00;
ANSELD = 0x00;
ANSELE = 0x00;
CM1CON0 = 0x07; // Disable Comparator 1.
CM2CON0 = 0x07; // Disable Comparator 2.
PORTA = 0; // Clear PORT A.
PORTB = 0; // Clear PORT B.
PORTC = 0; // Clear PORT C.
PORTD = 0; // Clear PORT D.
PORTE = 0; // Clear PORT E.
TRISA = 0xFF; // PORT A as Input.
TRISB = 0x00; // PORT B as Output.
TRISC = 0xF8; // Later.
TRISD = 0x2F; // RD <0 - 3 & 5> as Input, Rest as Output.
TRISE = 0xFF; // PORT E as Input.
LATA = 0x00;
LATB = 0x00;
LATC = 0x00;
LATD = 0x00;
LATE = 0x00;
//------- Clear or Set flags ---------------------------------------------------
while(1)
LATA = 0x00;
DELAY_MS(1000);
LATB = 0x00;
DELAY_MS(1000);
LATC = 0x00;
DELAY_MS(1000);
LATD = 0x00;
DELAY_MS(1000);
LATE = 0x00;
DELAY_MS(1000);
LATA = 0xFF;
DELAY_MS(1000);
LATB = 0xFF;
DELAY_MS(1000);
LATC = 0xFF;
DELAY_MS(1000);
LATD = 0xFF;
DELAY_MS(1000);
LATE = 0xFF;
DELAY_MS(1000);
}
| Thread starter | Similar threads | Forum | Replies | Date |
|---|---|---|---|---|
| T | RS232 to TTL custom board, no output from MAX232 | General Electronics Chat | 25 | |
| O | MAX232 for ±25V from 5V supply | General Electronics Chat | 35 | |
| T | Max232 capacitor placing issues | Microcontrollers | 11 | |
|
|
MAX232 Heating issue..! | General Electronics Chat | 23 | |
|
|
Question about serial comms between a pic and a pc using a max232 | Microcontrollers | 11 |