PRABAKARDEVA
Full Member level 2
- Joined
- Sep 16, 2013
- Messages
- 127
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,298
- Location
- Chennai
- Activity points
- 2,168
i didn't use more functions....calling the functions by two times....can u pls post any code for transmitting the data using uart?
Code C - [expand] 1 2 3 4 main() { main(); }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 main() { add(); } add() { multiply(); } multiply() { add(); }
#include<pic.h>
#include<htc.h>
__CONFIG(FOSC_HS & WDTE_OFF & BOREN_OFF & LVP_OFF & DEBUG_OFF);
#define _XTAL_FREQ 20000000
void main()
{
TRISC6=1;
TRISC7=1;
unsigned char x;
unsigned int rate=9600;
x=((_XTAL_FREQ-(16*rate))/(16*rate));
TXREG='0';
BRGH=1;
SPBRG=x;
SYNC=0;
SPEN=1;
TXEN=1;
CREN=1;
GIE=1;
PEIE=1;
TXIE=1;
RCIE=1;
while(!TXIF)
continue;
TXREG="HELLO";
}
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 #include<htc.h> __CONFIG(FOSC_HS & WDTE_OFF & BOREN_OFF & LVP_OFF & DEBUG_OFF); #define _XTAL_FREQ 20000000 void UART_Write(unsigned char uartData); void UART_Write_Text(unsigned char *uartData); void UART_Write(unsigned char uartData){ TXREG = uartData; while(!TXIF); } void UART_Write_Text(unsigned char *uartData){ while(*uartData) UART_Write(*uartData++); } void main(){ unsigned char x; unsigned int rate=9600; TRISC6=1; TRISC7=1; x = (_XTAL_FREQ - (16 * rate) / (16 * rate); BRGH = 1; SPBRG = x; SYNC = 0; SPEN = 1; TXEN = 1; CREN = 1; GIE = 1; PEIE = 1; TXIE = 1; RCIE = 1; INTCON = 0xC0; while(1){ UART_Write_Text("Hello"); //Add delay of 500 ms here } }
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 #include<htc.h> __CONFIG(FOSC_HS & WDTE_OFF & BOREN_OFF & LVP_OFF & DEBUG_OFF); #define _XTAL_FREQ 20000000 void UART_Write(unsigned char uartData); void UART_Write_Text(unsigned char *uartData); void UART_Write(unsigned char uartData){ TXREG = uartData; while(!TXIF); } void UART_Write_Text(unsigned char *uartData){ while(*uartData) UART_Write(*uartData++); } void main(){ unsigned char x; unsigned int rate=9600; TRISC6=1; TRISC7=1; x = (_XTAL_FREQ - (16 * rate) / (16 * rate); BRGH = 1; SPBRG = x; SYNC = 0; SPEN = 1; TXEN = 1; CREN = 1; GIE = 1; // PEIE = 1; TXIE = 1; RCIE = 1; // INTCON = 0xC0; while(1){ UART_Write_Text("Hello"); //Add delay of 500 ms here } }
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 #include<htc.h> __CONFIG(FOSC_HS & WDTE_OFF & BOREN_OFF & LVP_OFF & DEBUG_OFF); void UART_Write(unsigned char uartData); void UART_Write_Text(const char *uartData); void UART_Write(unsigned char uartData){ TXREG = uartData; while(!TXIF); } void UART_Write_Text(const char *uartData){ while(*uartData) UART_Write(*uartData++); } void main(){ TRISC6=1; TRISC7=1; BRGH = 1; SPBRG = 129; SYNC = 0; SPEN = 1; TXEN = 1; CREN = 1; while(1){ UART_Write_Text("Hello"); //Add delay of 500 ms here }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?