Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
/****************************************************************************** Copyright (c) 2008 [url=http://www.societyofrobots.com]www.societyofrobots.com[/url]* (please link back if you use this code!)** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License version 2 as* published by the Free Software Foundation.** Alternatively, this software may be distributed under the terms of BSD* license.*****************************************************************************/#include "pwm.c"#include "test.c"#include "beeper.c"void control(void){ //rprintfInit(uart1SendByte); //sets rprintf to USB (for terminal) //rprintf("\r\nStartup Aplication\n"); configure_ports(); LED_on(); while(1) { //... //test Line Following LF_test(); }}
//.../***************I2C Devices*******************///I2C Line Following Sensor Array#define ADDR 0x50#define BUFFSIZE 0x01int i2c_LF(void){ volatile u08 readbuffer=0x00; volatile u08 databuffer = 0; i2cMasterSend(ADDR, 0x01, &databuffer); i2cMasterReceive(ADDR, BUFFSIZE, &readbuffer); return readbuffer;}//...
//...void LF_test(void){ int a=0; u08 r=0x00; for(a=0;a<5;a++) { r=i2c_LF(); rprintf("\r\n Line Following: %d",r); delay_ms(100); }}//...
/****************************************************************************** Copyright (c) 2008 [url=http://www.societyofrobots.com]www.societyofrobots.com[/url]* (please link back if you use this code!)** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License version 2 as* published by the Free Software Foundation.** Alternatively, this software may be distributed under the terms of BSD* license.*****************************************************************************///SoR Include#include "SoR_Utils.h" //includes all the technical stuff#include "hardware.c" //declare hardware variables and ports#include "sensors.c" //sensor libraries for sonar, sharp IR, etc.#include "misc.c" //includes libraries for various hardware and other useful stuff#include "axon_DAQ.c" //use the Axon like a data acquisition device#include "control.c" //your code goes in here#include <string.h>#include "laser.c"#include "i2c.h"#include "i2c.c"int main(void){ //declare variables here int i=0;//useless variable int j=0;//useless variable //add 1.7s delay for potential power issues delay_cycles(65535); delay_cycles(65535); delay_cycles(65535); delay_cycles(65535); delay_cycles(65535); delay_cycles(65535); delay_cycles(65535); /****************INITIALIZATIONS*******************/ //other stuff Im experimenting with for SoR uartInit(); // initialize the UART (serial port) uartSetBaudRate(0, 38400); // set UARTE speed, for Bluetooth uartSetBaudRate(1, 115200); // set UARTD speed, for USB connection, up to 500k, try 115200 if it doesn't work //uartSetBaudRate(2, 19200); uartSetBaudRate(2, 38400); uartSetBaudRate(3, 38400); // set UARTJ speed, for Blackfin //G=Ground, T=Tx (connect to external Rx), R=Rx (connect to external Tx) rprintfInit(uart1SendByte);// initialize rprintf system and configure uart1 (USB) for rprintf //rprintfInit(uart2SendByte);//Sets UART2 as chosen in rprintf system configure_ports(); // configure which ports are analog, digital, etc. LED_on(); rprintf("\r\nSystem Warmed Up"); // initialize the timer system init_timer0(TIMER_CLK_1024); init_timer1(TIMER_CLK_64); init_timer2(TIMER2_CLK_64); init_timer3(TIMER_CLK_64); init_timer4(TIMER_CLK_64); init_timer5(TIMER_CLK_64); a2dInit(); // initialize analog to digital converter (ADC) a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage //let system stabelize for X time for(i=0;i<16;i++) { j=a2dConvert8bit(i);//read each ADC once to get it working accurately delay_cycles(5000); //keep LED on long enough to see Axon reseting rprintf("."); } LED_off(); LASER_off(); i2cInit(); //i2cSetBitrate(100); //i2cSetLocalDeviceAddr(0x42,TRUE); rprintf("Initialization Complete \r\n"); /**************************************************/ //wait until user pushes button rprintf("Waiting for Input \r\n"); while(!button_pressed()); //reset all timers to zero reset_timer0(); reset_timer1(); reset_timer2(); reset_timer3(); reset_timer4(); reset_timer5(); while(1) { control();//uncomment this for your code (and use control.c only to program) delay_cycles(100);//an optional small delay to prevent crazy oscillations } return 0;}
so this is making the first 5 calls to i2c_LF on the first call to control function finishes the control function delays loops, enters the control function then makes two calls to i2c crashes.correct?
the only things I can possibly come up with are dud connections on the PCB
issues with the other i2c device not working
source files having bugs or been acidently modified.
my best advice is check the wires, and rewrite the code with a fresh copy of the source files.
if that fails, I can't see the problem.
i2cMasterReceive(ADDR, BUFFSIZE, &readbuffer);
i2cMasterReceiveNI(ADDR, BUFFSIZE, &readbuffer);
#define ADDR 0x50#define BUFFSIZE 0x01u08 i2c_LF(void){ i2cInit(); volatile u08 readbuffer=0x00; volatile u08 databuffer = 0; i2cMasterSend(ADDR, 0x01, databuffer); i2cMasterReceiveNI(ADDR, BUFFSIZE, &readbuffer); return readbuffer;}