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???
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…