tag:blogger.com,1999:blog-7742255037214704776.post754017930031382249..comments2023-12-16T14:30:03.872-05:00Comments on Byte Cruft: Seeding the standard C random number generator on AVR chips.Pedantitehttp://www.blogger.com/profile/09869531706898136847noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-7742255037214704776.post-42194988164104119082016-05-16T00:02:53.492-04:002016-05-16T00:02:53.492-04:00Steve is correct. I just tested this behavior whil...Steve is correct. I just tested this behavior while programming for my ATMEGA644. If I read from ADC, no issues arise and I reliably generate new seeds (although close in value). If I read from ADCL without also reading from ADCH, all attempts at creating a new seed return the first value.<br /><br />Good catch Steve!JPLhttps://www.blogger.com/profile/09882192933511328372noreply@blogger.comtag:blogger.com,1999:blog-7742255037214704776.post-9115054605612245752014-11-18T15:38:20.763-05:002014-11-18T15:38:20.763-05:00Steve, that is a good catch! However, I wonder if ...Steve, that is a good catch! However, I wonder if this is an area where the datasheet is misleading, because the code seems to work. If I had to speculate, I'd say that the datasheet paragraph you quote might only apply to "autotriggering" mode of the ADC, which I'm not using here. The datasheet doesn't state that it is only for auto-triggered modes, but it wouldn't make a lot of sense to lock the register even in the face of a manually initiated capture. Pedantitehttps://www.blogger.com/profile/09869531706898136847noreply@blogger.comtag:blogger.com,1999:blog-7742255037214704776.post-47670498230065845372014-10-11T05:45:13.550-04:002014-10-11T05:45:13.550-04:00I may be misunderstanding the data sheet, but I th...I may be misunderstanding the data sheet, but I think you need to read ADCH after reading ADCL otherwise neither register will be updated when a new conversion completes:<br /><br />"Once ADCL is read, ADC access to data registers is blocked. This means that if ADCL has been read, and a conversion completes before ADCH is read, neither register is updated and the result from the conversion is lost. When ADCH is read, ADC access to the ADCH and ADCL Registers is re-enabled. "Stevehttps://www.cs.jhu.edu/~s/noreply@blogger.com