Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 364 → Rev 365

/roboti/Robotour/SW/motor/motor.PJT
0,0 → 1,40
[PROJECT]
Target=motor.HEX
Development_Mode=
Processor=0x688F
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Dr
Library=
LinkerScript=
 
[Target Data]
FileList=C:\dokumenty\svn\Kaklik\roboti\Robotour\SW\motor\motor.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[motor.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=motor.c
 
[Windows]
0=0000 motor.c 0 0 796 451 3 0
 
[Opened Files]
1=C:\dokumenty\svn\Kaklik\roboti\Robotour\SW\motor\motor.c
2=C:\dokumenty\svn\Kaklik\roboti\Robotour\SW\motor\motor.h
3=C:\Program Files\PICC\devices\16F88.h
4=
[Units]
Count=1
1=C:\dokumenty\svn\Kaklik\roboti\Robotour\SW\motor\motor.c (main)
/roboti/Robotour/SW/motor/motor.c
0,0 → 1,86
#include "motor.h"
#use i2c(Slave,Fast,sda=PIN_B1,scl=PIN_B4,force_hw,address=0xA0) // Motor 1
//#use i2c(Slave,Fast,sda=PIN_B1,scl=PIN_B4,force_hw,address=0xA2) // Motor 2
 
#define H1 PIN_A1
#define L1 PIN_A2
#define H2 PIN_A3
#define L2 PIN_A4
 
signed int8 command;
 
#INT_SSP
void ssp_interupt ()
{
BYTE incoming, state;
output_low(H1);
output_low(L1);
output_low(H2);
output_low(L2);
 
state = i2c_isr_state();
 
if(state < 0x80) //Master is sending data
{
output_toggle(PIN_A0);
command = i2c_read();
}
if(state == 0x80) //Master is requesting data
{
i2c_write(command);
}
}
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator(OSC_8MHZ|OSC_INTRC);
enable_interrupts(GLOBAL);
enable_interrupts(INT_SSP);
while(true)
{
 
if (0==command)
{
output_low(H1); // stop
output_low(H2);
output_low(L1);
output_low(L2);
continue;
};
if (command>0)
{
output_high(H1); // vpred
output_low(H2);
output_low(L1);
output_high(L2);
}
else
{
output_low(H1); // vzad
output_high(H2);
output_high(L1);
output_low(L2);
};
delay_us(127-abs(command));
output_low(H1);
output_low(H2);
output_low(L1);
output_low(L2);
}
}
 
 
 
/roboti/Robotour/SW/motor/motor.h
0,0 → 1,18
#include <16F88.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOIESO //Internal External Switch Over mode disabled
 
#use delay(clock=8000000)