#avr | Logs for 2016-10-16

Back
[00:05:26] <PoppaVic> OK, I think I see my bug. Anyone awake?
[00:06:17] <carabia> No. laters!
[00:06:17] <PoppaVic> I wrote my dospm() routine to re-enable RWW after ever call.. That erases the internal page-buff, doesn't it.
[00:25:37] <PoppaVic> well, fuckme
[00:50:10] <salad> I wasn't expecting that kind of proposition in #avr :o
[00:53:01] <PoppaVic> yeah, some folks get wet over graffiti
[00:53:36] <salad> I don't follow lol
[00:54:07] <PoppaVic> why not move back to the original question
[01:17:28] <PoppaVic> yeah.
[02:10:05] <tiblock> Hi. I need help here. I have self made atmega328p board and i try to make ADC work. I have this example https://gist.github.com/Wollw/2396604 and it is not working. So i took arduino with atmega328p and uploaded it there and added "Serial.print(adc_read(ADC_PIN));" and its always 1023. I tryed to connect PC0 to GND/3.3V/5V and its always 1023. Why is so? Is there error in example?
[02:10:11] <tiblock> Or i do something wrong?
[02:15:51] <tiblock> Ahhh, i see. "and the value 1023 means the voltage has reached the voltage on the AREF pin." and AREF is not connected anywhere on arduino and on my self made board too. Well, time to make new board with all mistake fixes i have.
[02:18:45] <tiblock> *I though its AVCC pin so i connected it to VCC but its AREF should be connected to VCC
[02:35:17] <sabor> tiblock: AREF can be connected internally
[02:35:37] <tiblock> sabor, what? How?
[02:37:22] <sabor> read about REFS1,REFS0 in ADMUX
[02:38:12] <sabor> you can choose between AVCC, an internal 1.1V voltage and a voltage on AREF
[02:53:36] <sabor> tiblock: you should also check th prescaler settings of the ADC
[02:54:06] <sabor> and in adc_read you have to wait for the ADIF bit, not ADSC
[02:54:53] <sabor> since you do not use the interrupt you have to clear the ADIF bit manually by writing 1 to it
[02:56:54] <tiblock> Well i found this code "/* Select Vref=AVcc */ ADMUX |= (1<<REFS0);" and with it when i connect PC0 to 5V its still 1023, when i connect to 3.3V its still 1023, when i connect to GND it randomly gives 1023 or 991. And its impossible to me found why and i still need capacotor for contact bouncing on my board so i will make new board with VREF connected to VCC
[03:02:33] <tiblock> I look at page 248 http://www.atmel.com/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf and it says if i do AREF to AVCC then i need capacitor on AREF pin so it still needs hardware changing
[03:04:19] <tiblock> And that randomly changes from 1023 to 991 may be reason because there is no capacitor
[03:36:22] <dgriffi> sabor: new troubles with the bluebox project... DTMF tones aren't well-accepted. I'll be trying to get a hold of an oscilloscope soon.
[03:45:57] <sabor> dgriffi: since it is audio you could also record it with a PC
[06:33:53] <salad> woo finished my tenth avr library
[15:41:16] <Posterdati> hi
[15:41:53] <Posterdati> is it possible to make a load or save indirect with displacement inside an 8 bit register?
[15:48:35] <CORDIC> Posterdati: Yes, `ld GPR ,Ptr ,D' instruction is equivalent to ``GPR = *(Ptr +D)''.
[15:49:01] <Posterdati> is D a register>
[15:49:02] <Posterdati> is D a register?
[15:49:39] <CORDIC> No, a constant encoded in `ld' or `st' Instruction.
[15:49:49] <Posterdati> is not what I asked for
[15:52:47] <CORDIC> k, I will read your mind.
[15:53:07] <Posterdati> is it possible to make a load or save indirect with displacement inside an 8 bit register?
[15:53:21] <Posterdati> "with displacement inside an 8 bit register"
[15:53:44] <CORDIC> Assmebly, C, or whatever?
[15:53:54] <Posterdati> assembly
[15:54:43] <CORDIC> I have no idea what ``inside an 8 bit register'' means.
[15:55:06] <CORDIC> Oops.
[15:55:07] <Posterdati> I added to the low pointer register y the displacement and then the carry only to the y pointer high part
[15:55:17] <CORDIC> Yes, but not in a single instruction.
[15:55:37] <Posterdati> there's no adc immediate :(
[15:55:41] <PoppaVic> cehteh: d'oh.. managed to get it all working. (stage 1 complete)..
[15:56:48] <CORDIC> ``sbci GPR ,-1'' is almost ``adci GPR ,1'', except SREG Flags.
[15:56:57] <PoppaVic> item: never trust avr-libc to not enable interrupts when yer back is turned; item: watch yer wrapper-routines; item: spm is just a pain in the dick.
[15:57:16] <PoppaVic> butt it now works as expected.
[15:58:52] <Posterdati> CORDIC: ldi yl,lo8(cdr) ldi yh,hi8(cdr) clc add yl,r17 sbci yh, -1
[15:58:53] <CORDIC> s/-1/1/
[15:59:54] <Posterdati> CORDIC: but the carry is subtracted :(
[16:00:14] <CORDIC> Sorry it is -1 which should be equivalent to 255.
[16:01:22] <Posterdati> CORDIC: so sbci yh, -1
[16:01:39] <CORDIC> ``brcc skip_it; inc YL; skip_it:'' is another way.
[16:02:12] <Posterdati> yes an incrementing loop
[16:02:58] <CORDIC> `cdr' sound familiar.
[16:06:54] <CORDIC> Posterdati: R17 is 1?
[16:07:45] <CORDIC> ``add YL ,R17; sbci YH ,-0''
[16:08:14] <CORDIC> `clc' before `add' is like a `nop'.
[16:14:54] <CORDIC> No it should be -1 to correct the Carry.
[16:56:26] <Posterdati> CORDIC: r17 is the variable displacement
[16:57:10] <Posterdati> CORDIC: ldi yl,lo8(cdr) ldi yh,hi8(cdr) clc adc yl,r17 sbci yh, -1
[16:57:51] <CORDIC> Replace ``clc adc'' with ``add''
[16:58:06] <Posterdati> yes add it is suffice
[17:10:39] <Posterdati> CORDIC: thanks!
[17:30:00] <CORDIC> O
[17:30:09] <CORDIC> OK