1
0
Fork 0

Additions from 17/12/2021: Speculation ? Interruption not working so going backward ?

This commit is contained in:
Yohan Boujon 2022-04-05 20:34:09 +02:00
parent 8730b36933
commit 2b1327994c
7 changed files with 120 additions and 120 deletions

View file

@ -179,7 +179,6 @@ defined( __AVR_ATtiny85__ )
(0<<USITC); \ (0<<USITC); \
USISR = (0<<USI_START_COND_INT)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)| /* Clear all flags, except Start Cond */ \ USISR = (0<<USI_START_COND_INT)|(1<<USIOIF)|(1<<USIPF)|(1<<USIDC)| /* Clear all flags, except Start Cond */ \
(0x0<<USICNT0); \ (0x0<<USICNT0); \
ADCSRA |= (1<<ADEN)|(1<<ADIE)|(1<<ADSC); \
} }

View file

@ -9,57 +9,57 @@
<CSub></CSub> <CSub></CSub>
<CVariant></CVariant> <CVariant></CVariant>
<CVendor>Atmel</CVendor> <CVendor>Atmel</CVendor>
<CVersion>1.8.0</CVersion> <CVersion>1.2.0</CVersion>
<DefaultRepoPath>D:/Programs\Atmelstudio\7.0\Packs</DefaultRepoPath> <DefaultRepoPath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs</DefaultRepoPath>
<DependentComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" /> <DependentComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<Description></Description> <Description></Description>
<Files xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <Files xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:anyType i:type="FileInfo"> <d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Programs\Atmelstudio\7.0\Packs\atmel\ATtiny_DFP\1.8.332\include\</AbsolutePath> <AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\include</AbsolutePath>
<Attribute></Attribute> <Attribute></Attribute>
<Category>include</Category> <Category>include</Category>
<Condition>C</Condition> <Condition>C</Condition>
<FileContentHash i:nil="true" /> <FileContentHash i:nil="true" />
<FileVersion></FileVersion> <FileVersion></FileVersion>
<Name>include/</Name> <Name>include</Name>
<SelectString></SelectString> <SelectString></SelectString>
<SourcePath></SourcePath> <SourcePath></SourcePath>
</d4p1:anyType> </d4p1:anyType>
<d4p1:anyType i:type="FileInfo"> <d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Programs\Atmelstudio\7.0\Packs\atmel\ATtiny_DFP\1.8.332\include\avr\iotn85.h</AbsolutePath> <AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\include\avr\iotn85.h</AbsolutePath>
<Attribute></Attribute> <Attribute></Attribute>
<Category>header</Category> <Category>header</Category>
<Condition>C</Condition> <Condition>C</Condition>
<FileContentHash>T0lnJZ6iliUJCzU7ZHCMPQ==</FileContentHash> <FileContentHash>RcYmivGpgsCGGCzeWAIjcA==</FileContentHash>
<FileVersion></FileVersion> <FileVersion></FileVersion>
<Name>include/avr/iotn85.h</Name> <Name>include/avr/iotn85.h</Name>
<SelectString></SelectString> <SelectString></SelectString>
<SourcePath></SourcePath> <SourcePath></SourcePath>
</d4p1:anyType> </d4p1:anyType>
<d4p1:anyType i:type="FileInfo"> <d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Programs\Atmelstudio\7.0\Packs\atmel\ATtiny_DFP\1.8.332\templates\main.c</AbsolutePath> <AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\templates\main.c</AbsolutePath>
<Attribute>template</Attribute> <Attribute>template</Attribute>
<Category>source</Category> <Category>source</Category>
<Condition>C Exe</Condition> <Condition>C Exe</Condition>
<FileContentHash>KjvOcFWd++tbnsEMfVPd/w==</FileContentHash> <FileContentHash>GD1k8YYhulqRs6FD1B2Hog==</FileContentHash>
<FileVersion></FileVersion> <FileVersion></FileVersion>
<Name>templates/main.c</Name> <Name>templates/main.c</Name>
<SelectString>Main file (.c)</SelectString> <SelectString>Main file (.c)</SelectString>
<SourcePath></SourcePath> <SourcePath></SourcePath>
</d4p1:anyType> </d4p1:anyType>
<d4p1:anyType i:type="FileInfo"> <d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Programs\Atmelstudio\7.0\Packs\atmel\ATtiny_DFP\1.8.332\templates\main.cpp</AbsolutePath> <AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\templates\main.cpp</AbsolutePath>
<Attribute>template</Attribute> <Attribute>template</Attribute>
<Category>source</Category> <Category>source</Category>
<Condition>C Exe</Condition> <Condition>C Exe</Condition>
<FileContentHash>mkKaE95TOoATsuBGv6jmxg==</FileContentHash> <FileContentHash>YXFphlh0CtZJU+ebktABgQ==</FileContentHash>
<FileVersion></FileVersion> <FileVersion></FileVersion>
<Name>templates/main.cpp</Name> <Name>templates/main.cpp</Name>
<SelectString>Main file (.cpp)</SelectString> <SelectString>Main file (.cpp)</SelectString>
<SourcePath></SourcePath> <SourcePath></SourcePath>
</d4p1:anyType> </d4p1:anyType>
<d4p1:anyType i:type="FileInfo"> <d4p1:anyType i:type="FileInfo">
<AbsolutePath>D:/Programs\Atmelstudio\7.0\Packs\atmel\ATtiny_DFP\1.8.332\gcc\dev\attiny85</AbsolutePath> <AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\gcc\dev\attiny85</AbsolutePath>
<Attribute></Attribute> <Attribute></Attribute>
<Category>libraryPrefix</Category> <Category>libraryPrefix</Category>
<Condition>GCC</Condition> <Condition>GCC</Condition>
@ -71,8 +71,8 @@
</d4p1:anyType> </d4p1:anyType>
</Files> </Files>
<PackName>ATtiny_DFP</PackName> <PackName>ATtiny_DFP</PackName>
<PackPath>D:/Programs/Atmelstudio/7.0/Packs/atmel/ATtiny_DFP/1.8.332/Atmel.ATtiny_DFP.pdsc</PackPath> <PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.2.118/Atmel.ATtiny_DFP.pdsc</PackPath>
<PackVersion>1.8.332</PackVersion> <PackVersion>1.2.118</PackVersion>
<PresentInProject>true</PresentInProject> <PresentInProject>true</PresentInProject>
<ReferenceConditionId>ATtiny85</ReferenceConditionId> <ReferenceConditionId>ATtiny85</ReferenceConditionId>
<RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">

View file

@ -34,17 +34,17 @@
<documentation help="" /> <documentation help="" />
<offline-documentation help="" /> <offline-documentation help="" />
<dependencies> <dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.42.0" /> <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.25.0" />
</dependencies> </dependencies>
</framework-data> </framework-data>
</AsfFrameworkConfig> </AsfFrameworkConfig>
<avrtool>com.atmel.avrdbg.tool.simulator</avrtool> <avrtool>com.atmel.avrdbg.tool.stk500</avrtool>
<avrtoolserialnumber /> <avrtoolserialnumber />
<avrdeviceexpectedsignature>0x1E930B</avrdeviceexpectedsignature> <avrdeviceexpectedsignature>0x1E930B</avrdeviceexpectedsignature>
<com_atmel_avrdbg_tool_stk500> <com_atmel_avrdbg_tool_stk500>
<ToolOptions> <ToolOptions>
<InterfaceProperties> <InterfaceProperties>
<IspClock>0</IspClock> <IspClock>125000</IspClock>
</InterfaceProperties> </InterfaceProperties>
<InterfaceName>ISP</InterfaceName> <InterfaceName>ISP</InterfaceName>
</ToolOptions> </ToolOptions>
@ -54,7 +54,7 @@
<ToolName>STK500</ToolName> <ToolName>STK500</ToolName>
</com_atmel_avrdbg_tool_stk500> </com_atmel_avrdbg_tool_stk500>
<avrtoolinterface>ISP</avrtoolinterface> <avrtoolinterface>ISP</avrtoolinterface>
<avrtoolinterfaceclock>0</avrtoolinterfaceclock> <avrtoolinterfaceclock>125000</avrtoolinterfaceclock>
<ResetRule>0</ResetRule> <ResetRule>0</ResetRule>
<EraseKey /> <EraseKey />
<com_atmel_avrdbg_tool_simulator> <com_atmel_avrdbg_tool_simulator>
@ -72,7 +72,7 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings> <ToolchainSettings>
<AvrGcc> <AvrGcc>
<avrgcc.common.Device>-mmcu=attiny85 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.8.332\gcc\dev\attiny85"</avrgcc.common.Device> <avrgcc.common.Device>-mmcu=attiny85 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.2.118\gcc\dev\attiny85"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex> <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss> <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep> <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
@ -87,7 +87,7 @@
</avrgcc.compiler.symbols.DefSymbols> </avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths> <avrgcc.compiler.directories.IncludePaths>
<ListValues> <ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.8.332\include\</Value> <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.2.118\include</Value>
</ListValues> </ListValues>
</avrgcc.compiler.directories.IncludePaths> </avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level> <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
@ -101,16 +101,16 @@
</avrgcc.linker.libraries.Libraries> </avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths> <avrgcc.assembler.general.IncludePaths>
<ListValues> <ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.8.332\include\</Value> <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.2.118\include</Value>
</ListValues> </ListValues>
</avrgcc.assembler.general.IncludePaths> </avrgcc.assembler.general.IncludePaths>
</AvrGcc> </AvrGcc>
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings> <ToolchainSettings>
<AvrGcc> <AvrGcc>
<avrgcc.common.Device>-mmcu=attiny85 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.8.332\gcc\dev\attiny85"</avrgcc.common.Device> <avrgcc.common.Device>-mmcu=attiny85 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.2.118\gcc\dev\attiny85"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex> <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss> <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep> <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
@ -125,7 +125,7 @@
</avrgcc.compiler.symbols.DefSymbols> </avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths> <avrgcc.compiler.directories.IncludePaths>
<ListValues> <ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.8.332\include\</Value> <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.2.118\include</Value>
</ListValues> </ListValues>
</avrgcc.compiler.directories.IncludePaths> </avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level> <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
@ -140,11 +140,11 @@
</avrgcc.linker.libraries.Libraries> </avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths> <avrgcc.assembler.general.IncludePaths>
<ListValues> <ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.8.332\include\</Value> <Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.2.118\include</Value>
</ListValues> </ListValues>
</avrgcc.assembler.general.IncludePaths> </avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel> <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc> </AvrGcc>
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -160,12 +160,6 @@
<Compile Include="led_receptor.h"> <Compile Include="led_receptor.h">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="led_test.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="led_test.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="main.c"> <Compile Include="main.c">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>

View file

@ -10,7 +10,7 @@
void led1_init(void) void led1_init(void)
{ {
DDRB |= (1<<PB1); DDRB |= (1<<PB1);
TCCR1|=(1<<CTC1)|(1<<COM1A0); //on active le mode CTC en comparant OCR1C, COM1A1 ? 1 pour desactiver /OC1A TCCR1|=(1<<CTC1)|(1<<COM1A0); //on active le mode CTC en comparant OCR1C, COM1A0 : mode toggle
OCR1C=16; //d'apres retroingenieurie OCR1C=16 OCR1C=16; //d'apres retroingenieurie OCR1C=16
TCCR1|=(1<<CS10); //on active la clock avec CS10 = 1, pas de prediv (plus precis pour haute freq) TCCR1|=(1<<CS10); //on active la clock avec CS10 = 1, pas de prediv (plus precis pour haute freq)
} }
@ -18,8 +18,8 @@ void led1_init(void)
void led2_init(void) void led2_init(void)
{ {
DDRB |= (1<<PB4); DDRB |= (1<<PB4);
GTCCR|=(1<<COM1B0); //COM1B0 a 1 pour desactiver /OC1A GTCCR|=(1<<COM1B0); //COM1B0 : mode toggle
OCR1B=16; //d'apres retroingenieurie OCR1B=16 OCR1C=16; //d'apres retroingenieurie OCR1C=16
TCCR1|=(1<<CS10); //on active la clock avec CS10 = 1, pas de prediv (plus precis pour haute freq) TCCR1|=(1<<CS10); //on active la clock avec CS10 = 1, pas de prediv (plus precis pour haute freq)
} }
@ -34,3 +34,9 @@ void led2_stop(void)
DDRB &= ~(1<<PB4); DDRB &= ~(1<<PB4);
GTCCR &= ~(1<<COM1B0); GTCCR &= ~(1<<COM1B0);
} }

View file

@ -45,22 +45,22 @@ float ADC_averaging(unsigned char val_ana)
float measureLed1(void) float measureLed1(void)
{ {
float adcLed; float adcLed;
led1_init(); //led1_init();
_delay_us(TIMING); //_delay_ms(TIMING);
adcLed=ADC_averaging(ADCH); adcLed=ADC_averaging(ADCH);
_delay_us(TIMING); //_delay_ms(TIMING);
led1_stop(); //led1_stop();
return adcLed; return adcLed;
}; };
float measureLed2(void) float measureLed2(void)
{ {
float adcLed; float adcLed;
led2_init(); //led2_init();
_delay_us(TIMING); //_delay_ms(TIMING);
adcLed=ADC_averaging(ADCH); adcLed=ADC_averaging(ADCH);
_delay_us(TIMING); //_delay_ms(TIMING);
led2_stop(); //led2_stop();
return adcLed; return adcLed;
}; };

View file

@ -11,7 +11,7 @@
#include "led_gen.h" #include "led_gen.h"
#include "USI_TWI_Slave.h" #include "USI_TWI_Slave.h"
#define F_CPU 8000000UL #define F_CPU 8000000
#include <util/delay.h> #include <util/delay.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
@ -21,7 +21,7 @@
#define NOTHING 0x54 #define NOTHING 0x54
#define ERROR 0xF0 #define ERROR 0xF0
#define VOLTMIN 1 #define VOLTMIN 1
#define TIMING 500 #define TIMING 100
void ADC_init(void); void ADC_init(void);
void ADC_start_conversion(void); void ADC_start_conversion(void);

View file

@ -16,7 +16,7 @@
#include "led_gen.h" #include "led_gen.h"
#include "led_receptor.h" #include "led_receptor.h"
#include "USI_TWI_Slave.h" #include "USI_TWI_Slave.h"
//#define F_CPU 1000000
#define NOM_CONSTRUC 0x08 #define NOM_CONSTRUC 0x08
#define NOM_CAPTEUR 0x10 #define NOM_CAPTEUR 0x10
#define VALEUR_DEMAN 0x49 #define VALEUR_DEMAN 0x49
@ -27,11 +27,11 @@ volatile float adcled1;
volatile float adcled2; volatile float adcled2;
volatile unsigned char recVal; volatile unsigned char recVal;
ISR (ADC_vect){//On récupère les données à chaque fin de conversion Analogique/Numérique /*ISR (ADC_vect){
adcled1=measureLed1(); adcled1=measureLed1();
adcled2=measureLed2(); adcled2=measureLed2();
recVal=compareLed(adcled1,adcled2); recVal=compareLed(adcled1,adcled2);
} }*/
int main( void ) int main( void )
{ {
@ -39,11 +39,12 @@ int main( void )
unsigned char nom_capteur[8]= {'T','u','r','k','i','s','h','Z'}; unsigned char nom_capteur[8]= {'T','u','r','k','i','s','h','Z'};
unsigned char sensor_type[8]= {'C','a','t','c','h','E','y','e'}; unsigned char sensor_type[8]= {'C','a','t','c','h','E','y','e'};
slaveAdress = 0x01; slaveAdress = 0x01;
MCUCR |= (1<<PUD);
USI_TWI_Slave_Initialise(slaveAdress); USI_TWI_Slave_Initialise(slaveAdress);
sei(); sei();
ADC_init(); //ADC_init();
ADC_start_conversion(); //ADC_start_conversion();
while(1) while(1)
{ {
@ -67,7 +68,7 @@ int main( void )
break; break;
case VALEUR_DEMAN : case VALEUR_DEMAN :
USI_TWI_Transmit_Byte(recVal); USI_TWI_Transmit_Byte(0x45/*recVal*/);
break; break;
case BASIC_MODE : case BASIC_MODE :