jjeevan007
Full Member level 5
- Joined
- Apr 13, 2012
- Messages
- 310
- Helped
- 44
- Reputation
- 88
- Reaction score
- 43
- Trophy points
- 1,308
- Location
- bangalore
- Activity points
- 2,782
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 69 70 71 72 73 74 75 76 77 78 79 #include<htc.h> #include<pic.h> //#include <pic16f877a.h> #define _XTAL_FREQ 4000000 __CONFIG(0x1f3a); void main(void) { ADCON1 =0x06 ; // Changes PORTA and PORTE to digital TRISA = 0x00 ; // Configure PORTA as output TRISD = 0X00 ; // Configure PORTD as output TRISB = 0x00 ; // Configure PORTB as output TRISC = 0x00 ; // Configure PORTC as output TRISE = 0x00 ; // Configure PORTE as output SPBRG=25; //setting the Baud Rate RCSTA=0X80; //Enabling the Serial Communication TXSTA=0X26; //Enabling Transmission in Serial Communication, Selecting Mode and Speed TXREG='H'; while(TXIF==0 || TRMT==0); TXREG='E'; while(TXIF==0 || TRMT==0); TXREG='L'; while(TXIF==0 || TRMT==0); TXREG='L'; while(TXLIF==0 || TRMT==0); TXREG='O'; while(TXIF==0 || TRMT==0); TXREG=' '; while(TXIF==0 || TRMT==0); TXREG='T'; while(TXIF==0 || TRMT==0); TXREG='E'; while(TXIF==0 || TRMT==0); TXREG='C'; while(TXIF==0 || TRMT==0); TXREG='H'; while(TXIF==0 || TRMT==0); TXREG='N'; while(TXIF==0 || TRMT==0); TXREG='O'; while(TXIF==0 || TRMT==0); TXREG='L'; while(TXIF==0 || TRMT==0); TXREG='O'; while(TXIF==0 || TRMT==0); TXREG='G'; while(TXIF==0 || TRMT==0); TXREG='Y'; while(TXIF==0 || TRMT==0); while(1); }
Hi to all,
i am trying to transmit the Data from PIC16F877A to PC using serial communication with following code.
Code:
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 69 70 71 72 73 74 75 76 77 78 79 #include<htc.h> #include<pic.h> //#include <pic16f877a.h> #define _XTAL_FREQ 4000000 __CONFIG(0x1f3a); void main(void) { ADCON1 =0x06 ; // Changes PORTA and PORTE to digital TRISA = 0x00 ; // Configure PORTA as output TRISD = 0X00 ; // Configure PORTD as output TRISB = 0x00 ; // Configure PORTB as output TRISC = 0x00 ; // Configure PORTC as output TRISE = 0x00 ; // Configure PORTE as output SPBRG=25; //setting the Baud Rate RCSTA=0X80; //Enabling the Serial Communication TXSTA=0X26; //Enabling Transmission in Serial Communication, Selecting Mode and Speed TXREG='H'; while(TXIF==0 || TRMT==0); TXREG='E'; while(TXIF==0 || TRMT==0); TXREG='L'; while(TXIF==0 || TRMT==0); TXREG='L'; while(TXLIF==0 || TRMT==0); TXREG='O'; while(TXIF==0 || TRMT==0); TXREG=' '; while(TXIF==0 || TRMT==0); TXREG='T'; while(TXIF==0 || TRMT==0); TXREG='E'; while(TXIF==0 || TRMT==0); TXREG='C'; while(TXIF==0 || TRMT==0); TXREG='H'; while(TXIF==0 || TRMT==0); TXREG='N'; while(TXIF==0 || TRMT==0); TXREG='O'; while(TXIF==0 || TRMT==0); TXREG='L'; while(TXIF==0 || TRMT==0); TXREG='O'; while(TXIF==0 || TRMT==0); TXREG='G'; while(TXIF==0 || TRMT==0); TXREG='Y'; while(TXIF==0 || TRMT==0); while(1); }
the problem is i am facing is the message "HELLO TECHNOLOGY" is receiving continuously
anyone help me so that it should send the message only once.....
Complier used is HI-TECH complier.
regards
jeevan
i have turned off the watch dog timer...........
__CONFIG(0x2F0A);
__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_ON & CP_OFF);
#ifndef _HTC_H_
#warning Header file pic16f877a.h included directly. Use #include <htc.h> instead.
#endif
/* header file for the MICROCHIP PIC microcontroller
* 16F877A
*/
#ifndef __PIC16F877A_H
#define __PIC16F877A_H
//
// Configuration mask definitions
//
// Config Register: CONFIG
#define CONFIG 0x2007
// Oscillator Selection bits
// RC oscillator
#define FOSC_EXTRC 0xFFFF
// HS oscillator
#define FOSC_HS 0xFFFE
// XT oscillator
#define FOSC_XT 0xFFFD
// LP oscillator
#define FOSC_LP 0xFFFC
// Watchdog Timer Enable bit
// WDT enabled
#define WDTE_ON 0xFFFF
// WDT disabled
#define WDTE_OFF 0xFFFB
// Power-up Timer Enable bit
// PWRT disabled
#define PWRTE_OFF 0xFFFF
// PWRT enabled
#define PWRTE_ON 0xFFF7
// Brown-out Reset Enable bit
// BOR enabled
#define BOREN_ON 0xFFFF
// BOR disabled
#define BOREN_OFF 0xFFBF
// Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit
// RB3/PGM pin has PGM function; low-voltage programming enabled
#define LVP_ON 0xFFFF
// RB3 is digital I/O, HV on MCLR must be used for programming
#define LVP_OFF 0xFF7F
// Data EEPROM Memory Code Protection bit
// Data EEPROM code protection off
#define CPD_OFF 0xFFFF
// Data EEPROM code-protected
#define CPD_ON 0xFEFF
// Flash Program Memory Write Enable bits
// Write protection off; all program memory may be written to by EECON control
#define WRT_OFF 0xFFFF
// 0000h to 00FFh write-protected; 0100h to 1FFFh may be written to by EECON control
#define WRT_256 0xFDFF
// 0000h to 07FFh write-protected; 0800h to 1FFFh may be written to by EECON control
#define WRT_1FOURTH 0xFBFF
// 0000h to 0FFFh write-protected; 1000h to 1FFFh may be written to by EECON control
#define WRT_HALF 0xF9FF
// In-Circuit Debugger Mode bit
// In-Circuit Debugger disabled, RB6 and RB7 are general purpose I/O pins
#define DEBUG_OFF 0xFFFF
// In-Circuit Debugger enabled, RB6 and RB7 are dedicated to the debugger
#define DEBUG_ON 0xF7FF
// Flash Program Memory Code Protection bit
// Code protection off
#define CP_OFF 0xFFFF
// All program memory code-protected
#define CP_ON 0xDFFF
#include<pic.h>
#include<htc.h>
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 69 70 71 72 73 74 75 76 77 78 #include<htc.h> #define _XTAL_FREQ 4000000 __CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_ON & CP_OFF); void main(void) { ADCON1 =0x06 ; // Changes PORTA and PORTE to digital TRISA = 0x00 ; // Configure PORTA as output TRISD = 0X00 ; // Configure PORTD as output TRISB = 0x00 ; // Configure PORTB as output TRISC = 0x00 ; // Configure PORTC as output TRISE = 0x00 ; // Configure PORTE as output SPBRG=25; //setting the Baud Rate RCSTA=0X80; //Enabling the Serial Communication TXSTA=0X26; //Enabling Transmission in Serial Communication, Selecting Mode and Speed TXREG='H'; while(TXIF==0 || TRMT==0); TXREG='E'; while(TXIF==0 || TRMT==0); TXREG='L'; while(TXIF==0 || TRMT==0); TXREG='L'; while(TXIF==0 || TRMT==0); TXREG='O'; while(TXIF==0 || TRMT==0); TXREG=' '; while(TXIF==0 || TRMT==0); TXREG='T'; while(TXIF==0 || TRMT==0); TXREG='E'; while(TXIF==0 || TRMT==0); TXREG='C'; while(TXIF==0 || TRMT==0); TXREG='H'; while(TXIF==0 || TRMT==0); TXREG='N'; while(TXIF==0 || TRMT==0); TXREG='O'; while(TXIF==0 || TRMT==0); TXREG='L'; while(TXIF==0 || TRMT==0); TXREG='O'; while(TXIF==0 || TRMT==0); TXREG='G'; while(TXIF==0 || TRMT==0); TXREG='Y'; while(TXIF==0 || TRMT==0); while(1); }
Power supply circuit is fine..........
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?