Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Looking for help for PIC16C745~~~

Status
Not open for further replies.

gomera

New Member
Hi everyone,

I'm doing the project of microcontroller(PIC16C745), here i want to light up one LED(RB2) and one buzzer(RB3) at the same time by pressing the switch(RB1), but the problem is that the LED can work but there is no response of the buzzer.

Here is my code of the program.
Thanks a lot!!!

#include <htc.h>
//#include "delay.h"
__CONFIG(WDTDIS&PWRTDIS&UNPROTECT&H4);

void init(void)
{
PORTB=0x02;
TRISB=0x02;
}

void initUSART(void)
{
TXSTA=0x22;
RCSTA=0x90;
SPBRG=0x9b;
}

void enter(void)
{
while(!TRMT);
TXREG=0x0d;
}

void tx_start(void)
{
while(!TRMT);
TXREG=0x1a;
}

void send_msg(const char*str)
{
char ps;
ps=*str;
while(ps>0)
{
str++;
if(ps==0)break;
while(!TRMT);
TXREG=ps;
ps=*str;
}
}

void main(void)
{
init();
initUSART();
while(1)
{
if(RB1==1)
{
RB3=0x01;
RB2=1;
send_msg("at+cmgf=1");
enter();
//Delay_Ms(50);
send_msg("at+cmgs=");
send_msg("+6583011234");
enter();
//Delay_Ms(50);
send_msg("hello");
tx_start();
//Delay_Ms(5000);

RB3=0;
RB2=0;
}
else if(RB1==0)
{
RB3=0;
RB2=0;
}
}
}

Can anyone give me some guide about this problem??? :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top