oTaRu
Junior Member level 2
l293d
Hi all,
I having a problem using the PIC16F877 to enable/disable L293D IC chip for enabling and disabling the DC motor.
I am using PORTD of PIC16F877 to control the enable pin 1 of L293D but it's seem not controlling at all.
here is the code:
//Define compiler error message.
#ifndef __CPU_16F877__
#error "This program is tailored for PIC16F877 controller"
#endif
//Include required header files here.
#include "io16f877.h" //the hardware register definition file.
/****************************************************************
The variable timer_value holds the count between two consecutive timer interrupts.
This is the desired time (sec) between interrupts divided by
the time period of each timer count.
E.g. in this program, TIMER1 is configured so that each count = 1.6 uS,
so timer_value of 60000 will give an interrupt period of 96 mS.
****************************************************************/
//int timer_value=0xEA60; //decimal 60000.
/**********************************************************************
Declare functions to be used in the main program, i.e.
void DelayUs(int count)
void initialize_IO_ports(void)
void wait()
**********************************************************************/
//Put the body of all these functions here, before isr() and main().
void DelayUs(int count)
{
int i;
int j;
for(i=0;i<count;i++)
{
for(j=0;j<5000000;j++);
//This for loop has 5 NOPs & wastes 1 uS for our PIC clock frequency of 20MHz.
}
}
void wait()
{
char i;
for(i=0;i<100;i++)
{
RD1 = 0;
DelayUs(100);
}
}
void initialize_IO_ports(void)
{
//set the digital IO ports as per requirement.
TRISB = 0xFF ; //portB as input.
TRISD = 0x00 ; //portD as output.
//clear the output ports at the beginning.
PORTD = 0x00 ; //clear portD.
}
void main()
{
//setup port D as output
while(1)
{
RD1=1;
wait();
//Stop
RD1=0;
wait();
}
}
Hi all,
I having a problem using the PIC16F877 to enable/disable L293D IC chip for enabling and disabling the DC motor.
I am using PORTD of PIC16F877 to control the enable pin 1 of L293D but it's seem not controlling at all.
here is the code:
//Define compiler error message.
#ifndef __CPU_16F877__
#error "This program is tailored for PIC16F877 controller"
#endif
//Include required header files here.
#include "io16f877.h" //the hardware register definition file.
/****************************************************************
The variable timer_value holds the count between two consecutive timer interrupts.
This is the desired time (sec) between interrupts divided by
the time period of each timer count.
E.g. in this program, TIMER1 is configured so that each count = 1.6 uS,
so timer_value of 60000 will give an interrupt period of 96 mS.
****************************************************************/
//int timer_value=0xEA60; //decimal 60000.
/**********************************************************************
Declare functions to be used in the main program, i.e.
void DelayUs(int count)
void initialize_IO_ports(void)
void wait()
**********************************************************************/
//Put the body of all these functions here, before isr() and main().
void DelayUs(int count)
{
int i;
int j;
for(i=0;i<count;i++)
{
for(j=0;j<5000000;j++);
//This for loop has 5 NOPs & wastes 1 uS for our PIC clock frequency of 20MHz.
}
}
void wait()
{
char i;
for(i=0;i<100;i++)
{
RD1 = 0;
DelayUs(100);
}
}
void initialize_IO_ports(void)
{
//set the digital IO ports as per requirement.
TRISB = 0xFF ; //portB as input.
TRISD = 0x00 ; //portD as output.
//clear the output ports at the beginning.
PORTD = 0x00 ; //clear portD.
}
void main()
{
//setup port D as output
while(1)
{
RD1=1;
wait();
//Stop
RD1=0;
wait();
}
}