Changeset - ebc4074e751f
[Not reviewed]
default
0 4 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2012-11-19 17:22:18
kripperger@CL-SEC241-09.cedarville.edu
Timer setup
4 files changed with 34 insertions and 11 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/spi.h
Show inline comments
 
@@ -10,13 +10,13 @@
 
#ifndef SPI_H_
 
#define SPI_H_
 

	
 
#include <avr/io.h>
 

	
 

	
 
#define SPI_SS_PIN PORTB4		//DEBUG //THIS IS WRONG FOR NOW...
 
#define SPI_SS_PIN PORTA1		//DEBUG 
 
#define SPI_SCK_PIN PORTB7
 
#define SPI_MOSI_PIN PORTB5
 
#define SPI_MISO_PIN PORTB6
 

	
 

	
 
// SPI clock modes
slave/slave/modules.c
Show inline comments
 
@@ -4,12 +4,14 @@
 
 * Created: 11/9/2012 11:44:22 AM
 
 *  Author: kripperger
 
 */ 
 
 
 #include <inttypes.h>
 
 #include <avr/io.h>
 
 #include "config.h"
 
 #include <util/delay.h>
 
 #include "modules.h"
 
 
 
 
 
 
 
 void modules_setup(uint8_t id)
 
 {
 
@@ -77,12 +79,18 @@
 
 {
 
	  
 
 }
 
  
 
 void modules_geiger_setup()
 
 {
 
	ASSR = 0x20;    //enable timer2 async mode with an external crystal
 
	_delay_ms(250); //let external 32KHz crystal stabilize
 
	TCCR2B = 0x05;  //set the prescaler to 128: 32.768kHz / 128 = 1Hz overflow
 
	TIFR2 = 0x1;    //reset timer2 overflow interrupt flag
 
	TIMSK2 = 0x01;  //enable interrupt on overflow
 
 
	  
 
 }
 
  
 
 void modules_cameras_setup()
 
 {
 
	  	  
slave/slave/slave.c
Show inline comments
 
@@ -12,31 +12,40 @@
 
 
 
#include "config.h"
 
 
#include <inttypes.h>
 
#include <avr/io.h>
 
#include <compat/twi.h>
 
#include <util/delay.h>
 
#include <compat/twi.h>
 
 
#include "modules.h"
 
//#include "lib/serial.h"		//Not made yet
 
#include "lib/led.h"
 
#include "lib/inputOutput.h"
 
#include "lib/i2c.h"
 
#include "lib/spi.h"
 
 
void micro_setup()
 
{
 
	// Generic microcontroller config options
 
	
 
	DDRA=0xFF; //PORTA is output //DEBUG
 
	
 
	
 
	DDRA = 0xFF;		//PORTA is output //DEBUG
 
 
 
 
 
 
}
 
 
ISR(TIMER2_OVF_vect)    //Timer 2 overflow interrupt handler
 
{
 
	// This executes every second.  Update real-time clocks
 
	// Used only in Geiger module
 
 
	
 
	TIFR2 = 0x1;    // Reset timer2 overflow interrupt flag 
 
}
 
 
 
int main(void)
 
{
 
	// Initialize
 
	micro_setup();			// Generic microcontroller config options
 
@@ -49,13 +58,14 @@ int main(void)
 
 
	
 
	
 
	uint8_t temp;	//DEBUG
 
	
 
	
 
	
 
	PORTA=0;//DEBUG
 
	temp=0;//DEBUG
 
	
 
    while(1)
 
    {
 
 
 
		modules_run(moduleID);
 
@@ -69,16 +79,16 @@ int main(void)
 
 
 
        //serial_SendCommand('0','A',0,0);	//DEBUG: EXAMPLE
 
        
 
        //i2c_write(RTC_ADDR, 0x05, 0x3A);	//DEBUG: EXAMPLE
 
 
        _delay_ms(10);
 
        temp = i2c_read(RTC_ADDR, 0x02);		//DEBUG: EXAMPLE: seconds
 
        //_delay_ms(10);
 
        //temp = i2c_read(RTC_ADDR, 0x02);		//DEBUG: EXAMPLE: seconds
 
        
 
        PORTA = temp;		//DEBUG
 
      //  PORTA = temp;		//DEBUG
 
 
 
 
    }
 
	
 
	return 0;
slave/slave/slave.cproj
Show inline comments
 
@@ -148,8 +148,13 @@
 
      <SubType>compile</SubType>
 
    </Compile>
 
  </ItemGroup>
 
  <ItemGroup>
 
    <Folder Include="lib" />
 
  </ItemGroup>
 
  <ItemGroup>
 
    <None Include="lib\SPIreadme.txt">
 
      <SubType>compile</SubType>
 
    </None>
 
  </ItemGroup>
 
  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
 
</Project>
 
\ No newline at end of file
0 comments (0 inline, 0 general)