Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with Programming PIC16F57 with PICKIT 3..!!

Status
Not open for further replies.

parthiv2eng

Member level 2
Joined
May 5, 2010
Messages
48
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Houston
Activity points
1,572
I am trying to burn PIC16F57 using PICKIT3 in circuit..but it won't work...Any suggestions..!!
 

Man, noone can help you if you describe your problem like this. The best answer would be like that:
Q: "I am trying to burn PIC16F57 using PICKIT3 in circuit..but it won't work...Any suggestions..!!"
A: "There is something wrong with MCU, hardware, software, your PC or Pickit or something else"

If you want us to help you provide most information you can such as:
-PC setup (hw and operating system)
-IDE setup (program in which you write code and compile it)\
-Interface firmware version (version of program which is running inside pickit)
-application circuit diagram
-software which you wrote and doesn't work
-what errors do you get? (if any show up)

BTW. Why would you use 16F57? Did you buy 1k pieces at bargain or what? It is too small for learning.
 

I have problem with ICSP. I dont hv any idea about hardware configuration to install firmware in PIC16F57. My code runs good in MPLAB simulation.

Attached Schematic.

I am trying to program RC5 remote so I got this schematic from one of the working remote and they used pic16f57 that's why I am using PIC16F57.

Code:
Code:
#include<htc.h>              //include MCU head file
__CONFIG(OSC_XT & WDT_OFF & CP_OFF);

#ifndef _XTAL_FREQ
 // Unless already defined assume 4MHz system frequency
 // This definition is required to calibrate __delay_us() and __delay_ms()
 #define _XTAL_FREQ 4000000
#endif

#define	PLAY		0x35
#define STOP 		0x36
#define PAUSE 		0x30
#define PREVTRACK 	0x21
#define NEXTTRACK 	0x20
#define REVERSE 	0x32
#define FASTFORWARD 0x34
#define SHUFFLE 	0x1C
#define REPEAT 		0x1D
#define VOLUMEUP 	0x14
#define VOLUMEDOWN 	0x15
#define MUTE 		0x0D
#define PROGRAM		0x24
#define STANDBY		0x0C
#define	DIM			0x10
#define DISC		0x2D
#define SCAN		0x2B
#define SOURCE		0x0E
#define PARITY		0x0A
#define AORB		0x3B
#define TIME		0x29
#define FAST		0x2F
#define UNDEFINE	0xFF			

#define ADDRESS		0x14
#define FALSE		0
#define TRUE		1

void send_code(unsigned char);
void transmit(unsigned char);

typedef struct
{
	unsigned char bit_mask;			//used to create a serial data stream
	unsigned int k;
	unsigned int count;
	unsigned char key;
	unsigned char row;
} REMOTE;

volatile REMOTE remote;

//---------------------------------------------------
                             //main program  
void main()
{
  while(1)                   //circle work                        
    {                                                            
		TRISA=0x00;                 //PORTA OUTPUT    
		TRISB=0xFF;                 //PORTB INPUT
		TRISC=0x00;                 //PORTC OUTPUT
		RA3 = 1;
		remote.key = 0;
		remote.row = 0;				                      
      	for( remote.row = 0b00000001; remote.row < 0b01000000; remote.row<<=1) 
    	{  			
        	{
				RC0 = 0;
				RC1 = (~remote.row)>>1;
				RC2 = (~remote.row)>>2;
				RC3 = (~remote.row)>>3;
				RC4 = (~remote.row)>>4;
				RC5 = (~remote.row)>>5;
				RC6 =	1;
				RC7 =	1;
			}
			
 			// read colums - break when key press detected 
        	if(RB0)break;  	remote.key++; 
        	if(RB1 )break;  remote.key++; 
			if(RB2)break;  	remote.key++; 
			if(RB3)break;  	remote.key++; 
			if(RB4)break;  	remote.key++;
			if(RB5)break;  	remote.key++; 
			if(RB6)break;  	remote.key++;
			if(1)break;  	remote.key++;		 
   		} 

   		RC1 = 1; 
    	RC2 = 1; 
    	RC3 = 1; 
    	RC4 = 1;
		RC5 = 1; 
		
	  switch(remote.key)
		{	
			case 0:		send_code(UNDEFINE); break;
			case 1:		send_code(STANDBY); break;
			case 2:		send_code(UNDEFINE); break;
			case 3:		send_code(UNDEFINE); break;
			case 4:		send_code(DISC); break;
			case 5:		send_code(UNDEFINE); break;
			case 6:		send_code(UNDEFINE); break;
			case 7:		send_code(AORB); break;
			case 8:		send_code(UNDEFINE); break;
			case 9: 	send_code(1); break;
			case 10: 	send_code(4); break;
			case 11:	send_code(7); break;
			case 12: 	send_code(UNDEFINE); break;
			case 13: 	send_code(SCAN); break;
			case 14: 	send_code(FAST); break;
			case 15: 	send_code(SHUFFLE); break;
			case 16: 	send_code(UNDEFINE); break;
			case 17: 	send_code(2); break;
			case 18:	send_code(5); break;
			case 19:	send_code(8); break;
			case 20:	send_code(0); break;
			case 21:	send_code(PROGRAM); break;
			case 22:	send_code(REVERSE); break;
			case 23:	send_code(PREVTRACK); break;
			case 24:	send_code(UNDEFINE); break;
			case 25:	send_code(3); break;
			case 26:	send_code(6); break;
			case 27:	send_code(9); break;
			case 28:	send_code(UNDEFINE); break;
			case 29:	send_code(TIME); break;
			case 30:	send_code(FASTFORWARD); break;
			case 31:	send_code(NEXTTRACK); break;
			case 32:	send_code(REPEAT); break;
			case 33:	send_code(PAUSE); break;
			case 34:	send_code(STOP); break;
			case 35:	send_code(UNDEFINE); break;
			case 36:	send_code(UNDEFINE); break;
			case 37:	send_code(UNDEFINE); break;
			case 38:	send_code(UNDEFINE); break;
			case 39:	send_code(UNDEFINE); break;
			case 40:	send_code(PLAY); break;
			case 41:	send_code(UNDEFINE); break;
			case 42:	send_code(UNDEFINE); break;
			case 43:	send_code(UNDEFINE); break;
			case 44:	send_code(UNDEFINE); break;
			case 45:	send_code(UNDEFINE); break;
			case 46:	send_code(UNDEFINE); break;
			case 47:	send_code(UNDEFINE); break;
			default:	break;
		} 			
      	
	}	 
}			 
void send_code(unsigned char button)
{       
	 //BUTTON DOWN
	remote.bit_mask = 0x10;
	// Send two start bits
	RA3 = FALSE;
	__delay_us(889);
	RA3 = TRUE;
	__delay_us(889);
	RA3 = FALSE;
	__delay_us(889);
	RA3 = TRUE;
	__delay_us(889);

	// Send a toggle bit - 1
	RA3 = FALSE;
	__delay_us(889);
	RA3 = TRUE;
	__delay_us(889);
	// Send address - 5 bits
	for (remote.k = 0;  remote.k < 5; remote.k++)
	{
		if ((ADDRESS & remote.bit_mask) > 0)
			{
				RA3 = FALSE;
				__delay_us(889);
				RA3 = TRUE;
				__delay_us(889);
			}	 

		else 
			{
				RA3 = TRUE;
				__delay_us(889);
				RA3 = FALSE;
				__delay_us(889);
			}

		// Shift remote.bit_mask right 1 bit 0x10->0x08->0x04->0x02->0x01
		remote.bit_mask = remote.bit_mask >> 1;   
	}  

	//Send button command
	remote.bit_mask = 0x20;
	// 6 data bits, MSB first       
	for (remote.k = 0;  remote.k < 6; remote.k++)
	{
		if ((button & remote.bit_mask) > 0) 
			{
				RA3 = FALSE;
				__delay_us(889);
				RA3 = TRUE;
				__delay_us(889);
			}	 

		else 
			{
				RA3 = TRUE;
				__delay_us(889);
				RA3 = FALSE;
				__delay_us(889);
			}

		// Shift remote.bit_mask right 1 bit 0x20->0x10->0x08->0x04->0x02->0x01
		remote.bit_mask = remote.bit_mask >> 1;   
	}  

	//BUTTON UP
	remote.bit_mask = 0x10;                    
    // Send two start bits
	RA3 = FALSE;
	__delay_us(889);
	RA3 = TRUE;
	__delay_us(889);
	RA3 = FALSE;
	__delay_us(889);
	RA3 = TRUE;
	__delay_us(889);

	// Send a toggle bit - 0
	RA3 = TRUE;
	__delay_us(889);
	RA3 = FALSE;
	__delay_us(889);

	// Send address - 5 bits
	for (remote.k = 0;  remote.k < 5; remote.k++)
	{
		// determine whether to put a 0 or 1 on to the DATA pin
		if ((ADDRESS & remote.bit_mask) > 0)
			{
				RA3 = FALSE;
				__delay_us(889);
				RA3 = TRUE;
				__delay_us(889);
			}	 

		else 
			{
				RA3 = TRUE;
				__delay_us(889);
				RA3 = FALSE;
				__delay_us(889);
			}

		// Shift remote.bit_mask right 1 bit 0x10->0x08->0x04->0x02->0x01
		remote.bit_mask = remote.bit_mask >> 1;   
	}  

	//Send button command
	remote.bit_mask = 0x20;
	// 6 data bits, MSB first       
	for (remote.k = 0;  remote.k < 6; remote.k++)
	{
		// determine whether to put a 0 or 1 on to the DATA pin
		if ((button & remote.bit_mask) > 0) 
			{
				RA3 = FALSE;
				__delay_us(889);
				RA3 = TRUE;
				__delay_us(889);
			}	 

		else 
			{
				RA3 = TRUE;
				__delay_us(889);
				RA3 = FALSE;
				__delay_us(889);
			}

		// Shift remote.bit_mask right 1 bit 0x20->0x10->0x08->0x04->0x02->0x01
		remote.bit_mask = remote.bit_mask >> 1;   
	}  
}
 

Attachments

  • untitled.JPG
    untitled.JPG
    95.9 KB · Views: 149
  • untitled1.JPG
    untitled1.JPG
    156.2 KB · Views: 119

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top