Sara89
Banned
- Joined
- Dec 22, 2013
- Messages
- 18
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 0
hi i am doing a project and my prof asked us not to use any library,, so i am writing my own code and send, receive functions but i am having some troubles...
here's my code can anyone help plz as soon as possible ...
thank you
here's my code can anyone help plz as soon as possible ...
thank you
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 void USART_init(void); void USART_trans_char(unsigned char x); void USART_trans_string(char *z, int b); void delay(void); unsigned char myflag=0; char AT[] = {'A','T'}; char CMGF[] = {'C','M','G','F'}; char CMGS[] = {'C','M','G','S'}; char msg[] = {'O','K'}; char phone[] = {'0','7','9','5','9','8','2','7','2','6'}; void main() { USART_init (); delay_ms(00); USART_trans_string(AT, strlen(AT)); delay_ms(500); USART_trans_char (13); USART_trans_char (10); USART_trans_string(AT,strlen(AT)); USART_trans_char (43); //+ USART_trans_string (CMGF, strlen(CMGF)); USART_trans_char (61); //= USART_trans_char (49); //1 USART_trans_char (13); USART_trans_char (10); delay_ms(2500); USART_trans_string(AT,strlen(AT)); USART_trans_char (43); //+ USART_trans_string (CMGS, strlen(CMGS)); USART_trans_char (61); //= USART_trans_char (34); USART_trans_string (phone, strlen (phone)); USART_trans_char (34); USART_trans_char (13); USART_trans_char (10); delay_ms(2500); USART_trans_string (msg, strlen(msg)); USART_trans_char (13); USART_trans_char (10); delay_ms(2500); } void USART_init(void){ TXSTA=0x22; // low speed communication, asynchronous, Tx enable, 8 bit data RCSTA=0x90;// serial port enable, 8 bit data, continuous Rx, no address detection SPBRG=12;//9600 bps TRISC=0x80; //RC7 is Rx while RC6 is Tx INTCON=0xC0; // GIE and PEIE PIE1=PIE1|0x20;// Enable USART Rx interrupt } void USART_trans_char(unsigned char x){ while(!(TXSTA& 0x02)); TXREG=x; } void USART_trans_string(char* z, int b){ int i =0; for (i=0; i<b; i++){ USART_trans_char(z[i]); }}
Last edited by a moderator: