Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Serial Interrupt during ADC conversion

Status
Not open for further replies.

savvej

Member
In my code I am using Serial Interrupt to watch values of various variables in realtime.
In the main function,I call ADC conversion(Single) running in a while(1) loop.As soon as I transmit serial data,it receives an interrupt and sends me the value of variables I want and also I update values of variables I want.
In the process of writing code I encountered following problems:

1)Firstly,updating of global variables in interrupt routine doesnt work until and unless I turn off all Optimization and set it to 0o.Hence my code size increases drastically and it requires lot of time to program via USBASP.Is there any trick by which I can keep O2 optimization as well as use global variables?

2)What happens if serial interrupt occurs in between adc conversion process?Will the uC complete ADC conversion and then goto ISR or will it directly go?in the other case aint I going to get invalid value?

3)I am using atmega 32 internal osc configured at 8Mhz and 19200 baud rate.But the data which I receive serially from uC is corrupted at times showing garage characters .Datasheet shows that at 8Mhz and 19200 baud rate error of UART is around 0.2% .Is it becuase of this error or is it that my internal oscillator needs calibration?Should I replace it with an external oscillator ?Or is it due to power supply noise or AVR ADC/Core noise causing the transmission error?Also I have a PWM ouput whose value depends on ADC input and gets updated in main function.Can PWM introduce noise which communication?

4)While programming the uC many a times,it shows invalid device signature.And upon checking the fuse bits it shows that they unexpectedly get changed.Then I need to supply external clock and reset fuses and agaian program the uC.What could be possible reading for uC behaving this way?

5)For reset I manually connect wire to RESET pin and ground it.But in many circuits ,they use a RC circuit connected to reset .What is the reason for this? BTW my SUT bits are configured as 10 => slowly rising power supply.Is the RC circuit necessary? and how to SUT bits affect the reset procedure?Also what is the exact purpose of Brownout trigger level pin and brown out reset?
 
For serial comunication I would always take an external Crystal, because the internal Oscillator has an teperature drift.
So you can get problems with the Comunication, that appends from the Temperature.
 
Yes,I agree.But when using a breadboard with ISP header on breadboard;it becames mandatory for me to remove the ISP header to allow for connections of cystal's capacitors-which necessiates removing and adding header again and again while debugging.Excepting that I swear for my new development board board I will surely use crystal.
In my case the problem got solved changing calibration byte as by default whatever internal RC oscillator frequency you use,by default the calibration byte corresponding to 1Mhz only gets loaed.To solve this problem one needs to read calibration byte using programmer and then put corresponding calibration byte of 8Mhz in OSCCAl register in the software code so as to load this value during startup.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top