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 31 insertions and 8 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/spi.h
Show inline comments
 
@@ -13,7 +13,7 @@
 
#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
slave/slave/modules.c
Show inline comments
 
@@ -7,6 +7,8 @@
 
 
 #include <inttypes.h>
 
 #include <avr/io.h>
 
 #include "config.h"
 
 #include <util/delay.h>
 
 #include "modules.h"
 
 
 
 
 
@@ -80,6 +82,12 @@
 
  
 
 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
 
 
	  
 
 }
 
  
slave/slave/slave.c
Show inline comments
 
@@ -15,9 +15,8 @@
 
 
#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"
 
@@ -28,12 +27,22 @@
 
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)
 
@@ -52,7 +61,8 @@ int main(void)
 
	uint8_t temp;	//DEBUG
 
	
 
	
 
	
 
	PORTA=0;//DEBUG
 
	temp=0;//DEBUG
 
	
 
    while(1)
 
    {
 
@@ -72,10 +82,10 @@ int main(void)
 
        
 
        //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
 
 
 
slave/slave/slave.cproj
Show inline comments
 
@@ -151,5 +151,10 @@
 
  <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)