tag:blogger.com,1999:blog-6245413346375218188.post3714509321303125562..comments2024-03-15T05:42:04.481-07:00Comments on Nerd Ralph: Writing AVR assembler code with the Arduino IDERalph Doncasterhttp://www.blogger.com/profile/00037504544742962130noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-6245413346375218188.post-62170105212838959812017-05-21T04:04:34.574-07:002017-05-21T04:04:34.574-07:00I love OnePinSerial , it seems to work on most avr...I love OnePinSerial , it seems to work on most avr's i have tried albeit @ 8mhz. It inspired me to write my own library, previously being told attiny's won't work with rfm92/95/96/97/98 aka sx127x radios. So i wrote my own ISM_SPI library to get the size down, So with ISM_RADIO & OnePinSerial , i only use just under 3-4k for 8-16kb tinys & 7kb for atmega32u4, 4kb for 328P.<br /><br />I would really like to optimise my libraries with assembler is that something you offer as a service, if so please give me a dingle :)<br />JB_AUhttps://www.blogger.com/profile/09946483270252331706noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-73881496071402806222017-05-05T06:18:54.802-07:002017-05-05T06:18:54.802-07:00Hi Kev,
Sorry for the slow response. I've use...Hi Kev,<br />Sorry for the slow response. I've used the code on a 328 (pro mini clone). If you only need one serial port it's best to use the hardware USART though.Ralph Doncasterhttps://www.blogger.com/profile/00037504544742962130noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-37461876081024763942017-05-05T06:06:18.055-07:002017-05-05T06:06:18.055-07:00Just noticed your comment in the moderation queue....Just noticed your comment in the moderation queue. To avoid timing issues you could try either lowering the baud rate, or adjusting the OSCCAL register.Ralph Doncasterhttps://www.blogger.com/profile/00037504544742962130noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-81824262384285417502017-04-22T14:22:28.752-07:002017-04-22T14:22:28.752-07:00I am semi-successful using the bbuart code. I say ...I am semi-successful using the bbuart code. I say "semi" because I get a lot of errors. I suspect timing issues. I am running a ATTiny85-20SU at @8MHz at 3.3Vcelemhttps://www.blogger.com/profile/08902833703052607345noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-64447583876077596212017-03-03T02:57:15.724-08:002017-03-03T02:57:15.724-08:00Hi Ralph, a great bit of code for reducing program...Hi Ralph, a great bit of code for reducing program size - can it be used on other CPU's - 32u4, 328, etc?<br /><br />Thanks very much, KevKevWalhttps://www.blogger.com/profile/02260304801472450711noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-41108736043156170652016-09-27T09:05:06.687-07:002016-09-27T09:05:06.687-07:00If you're getting the serial port output, the ...If you're getting the serial port output, the problem is with your C code.<br />If there is no loop in your main(), that would explain why you do not see your LED blink. If you do have a loop, I'd suggest posting the full code to avrfreaks.net and maybe someone there will help you.Ralph Doncasterhttps://www.blogger.com/profile/00037504544742962130noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-85288476625858577502016-09-26T18:02:51.840-07:002016-09-26T18:02:51.840-07:00Great work on this! I am a bit weak on assembly, b...Great work on this! I am a bit weak on assembly, but attempted to incorporate your script into an avr-gcc test program. It spits out properly to the serial port, but the c routine does not blink the led or delay. Condensed main.c:<br /><br />void serOut(const char* str)<br />{<br /> while (*str) TxTimedByte (*str++,TXDELAY);<br />}<br /><br />main...<br />DDRB |= (1<<PINB5); // set LED pin to output mode<br />serOut("Toggle LED\r\n");<br />PORTB ^= (1<<PINB5); // toggle LED<br />_delay_ms(100); // 0.1 second delay<br /><br />Also I had to remove extern "C" from the header:<br />What am I doing wrong?<br /><br />ThanksAnonymoushttps://www.blogger.com/profile/12492651153744623288noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-19109732129309719912016-08-17T06:13:14.407-07:002016-08-17T06:13:14.407-07:00Hi I am new assembly language,i am working with ar...Hi I am new assembly language,i am working with arduino. I wanna fetch the data from co2 sensor. To do so, i need to write the following command which is written in assembly, could anyone help me to write the same code in arduino.<br />send command 80h 02h 00h 7Eh to co2 sensor system until uplink response with type being 80hWorkshophttps://www.blogger.com/profile/12294227142620669025noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-85079936867957116142016-05-31T07:31:05.854-07:002016-05-31T07:31:05.854-07:00i made it to work in the end :))
the problem was t...i made it to work in the end :))<br />the problem was that i didn't uploaded a blank sketch on the arduino boardAnonymoushttps://www.blogger.com/profile/01184015592829125790noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-16941372070739757432016-05-31T06:50:57.391-07:002016-05-31T06:50:57.391-07:00hi, i'm using your method but i get "aaa ...hi, i'm using your method but i get "aaa aaa aaa" on the serial monitor I'm using a linux machine, could this be the problem?Anonymoushttps://www.blogger.com/profile/01184015592829125790noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-87564250241711474082016-04-11T16:05:22.915-07:002016-04-11T16:05:22.915-07:00Changing UART_Tx should do the trick. The way the...Changing UART_Tx should do the trick. The way the Arduino IDE does dependencies is a bit quirky so maybe it's not recompiling the .S file when you make the change. I do most of my programming from the command line using makefiles, so I don't know how to force a compile of all files in the IDE. Another option would be to find the temporary .o files and delete them.Ralph Doncasterhttps://www.blogger.com/profile/00037504544742962130noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-87439869336408936502016-04-11T13:49:05.881-07:002016-04-11T13:49:05.881-07:00Hi, I use ATTiny85 with your soft. I try to change...Hi, I use ATTiny85 with your soft. I try to change le Tx pin but it's alway pin 5 (on IC) == pin PB0 on tiny85. I change #define UART_Tx 0 with #define UART_Tx 3 , but I have no change in test.<br />How change it ?<br />Think<br />Anonymoushttps://www.blogger.com/profile/03433244886603249468noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-75189249548622664922016-01-28T20:00:11.693-08:002016-01-28T20:00:11.693-08:00The txdelay is 21 for 8Mhz and 44 for 16Mhz. See ...The txdelay is 21 for 8Mhz and 44 for 16Mhz. See the #if F_CPU ... lines. The delay loop is 3 cycles, so the delay is 3x tx delay (see code comments)<br /><br />In V2, the txdelay is passed to the txbyte function along with the character to output.Ralph Doncasterhttps://www.blogger.com/profile/00037504544742962130noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-23141742521242651022016-01-26T03:51:05.559-08:002016-01-26T03:51:05.559-08:00Hello Ralph,
Two questions,
(1) in the code abov...Hello Ralph, <br />Two questions, <br />(1) in the code above, how do you calculate the TXDELAY? At F_CPU=8MHZ and baud 115200, it would need (8x 10^6 / 115200) clock cycles to shift one symbol, i.e. 69 CLK cycles. How do you calculate TXDELAY=44? <br /><br />(2) in the new code, version 2 updated here, How does the assembly routine get the TXDELAY calculated via macro in header file? <br />I see this in comment " transmit byte in r24 with bit delay in r22 - 15 instructions" <br />It would help people not familiar with assembly and assembly-c interface.<br /><br />Many Thanks<br />rjha94https://www.blogger.com/profile/08400721290752890010noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-68699407960050291632015-08-06T13:13:23.533-07:002015-08-06T13:13:23.533-07:00I generally avoid file upload sites; they usually ...I generally avoid file upload sites; they usually have annoying pop-ups, and some have been known to wrap files in an installer that contains malware.<br />Since writing this post, I've updated my soft uart, and pushed it to my github account:<br />https://github.com/nerdralph/nerdralph/tree/master/avr/libs/bbuart<br /><br />You might consider publishing your code on github or bitbucket so it is more accessible.Ralph Doncasterhttps://www.blogger.com/profile/00037504544742962130noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-47771663914880033622015-08-06T09:52:35.787-07:002015-08-06T09:52:35.787-07:00I hacked together a little Arduino Library, workin...I hacked together a little Arduino Library, working on Arduino 1.6.4 with the Streaming library:<br /><br />http://www.file-upload.net/download-10823054/attiny85ser.rar.html<br /><br />attiny85ser s = attiny85ser();<br /><br />s << "[INFO] ledblink_wheel pos: " << pos << " pause: " << pause << endl;<br /><br />Working like a charm, might be not the most efficient way but .. it is working.<br /><br /><br /><br />Darkdoomhttps://www.blogger.com/profile/18099315804962320632noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-4831320414273060382015-08-06T09:16:54.087-07:002015-08-06T09:16:54.087-07:00This comment has been removed by the author.Darkdoomhttps://www.blogger.com/profile/18099315804962320632noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-34654765031400169112014-05-26T10:38:33.304-07:002014-05-26T10:38:33.304-07:00Turns out it was a Ubuntu issue, their version of ...Turns out it was a Ubuntu issue, their version of 1.0.5 is not the same as the released version.Anonymoushttps://www.blogger.com/profile/15819496995233191046noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-32583665241915964952014-05-24T13:04:05.545-07:002014-05-24T13:04:05.545-07:00I've tested it with 1.0.4, 1.0.5-r2, and the 1...I've tested it with 1.0.4, 1.0.5-r2, and the 1.5 beta (nightly build).<br />Ralph Doncasterhttps://www.blogger.com/profile/00037504544742962130noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-87002804674021824762014-05-23T15:12:18.750-07:002014-05-23T15:12:18.750-07:00I get an error with avr-gcc saying that "-ass...I get an error with avr-gcc saying that "-assembler-with-cpp" is an unrecognized option. Which version of Arduino/avr-gcc are you using?Anonymoushttps://www.blogger.com/profile/15819496995233191046noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-48554787810798335792014-02-19T21:01:38.387-08:002014-02-19T21:01:38.387-08:00Just noticed your comments in the "awaiting m...Just noticed your comments in the "awaiting moderation" list. I adjusted the moderation settings so that shouldn't happen again. Good work getting it working with interrupts. With the interrupt trigger, RxTimedByte won't need to check for the start bit - maybe you already removed that.<br />I didn't pull up the datasheet, but I think you can set the interrupt to be active low only, that way you won't need the check for high to low transition (which should only ever happen inside the interrupt, and therefore you should never see it anyway).<br />Ralph Doncasterhttps://www.blogger.com/profile/00037504544742962130noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-85940014415382060452014-01-23T10:04:23.485-08:002014-01-23T10:04:23.485-08:00Hello!
Got it working interrupt driven by pin chan...Hello!<br />Got it working interrupt driven by pin change int, a fifo buffer and a single pin on tiny85. Just adjusted a bit the receive delays due interrupt latency. Here is my code in case of someone interest:<br />init_uart:<br /> sbi UART_Port, UART_Rx ;rx pullup high<br /> sbi UART_Ddr, UART_Rx ;tx/rx = out <br /> in r24, GIMSK ;enable pin change int<br /> ori r24, (1 << PCIE)<br /> out GIMSK, r24<br /> sbi PCMSK, PCINT3 <br /> ret<br /><br />PCINT0_vect:<br /> push r24<br /> in r24, SREG<br /> push r24<br /> in r24, PINB<br /> sbrc r24, UART_Rx ;act on high to low transitions only<br /> rjmp PCINT0_vect_exit<br /><br /> ldi r24, ASM_RXDELAY_15<br /> ldi r22, ASM_RXDELAY_1<br /><br /> rcall RxTimedByte<br /><br /> sts rx_byte, r24 ;new byte<br /><br /> rcall rx_fifo_store ;store new byte in fifo<br /><br /> PCINT0_vect_exit:<br /> pop r24<br /> out SREG, r24<br /> pop r24<br /> reti <br /><br />Many thanks Ralph!Porotitohttps://www.blogger.com/profile/10115175179646525710noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-48943263266130269312014-01-22T15:08:38.815-08:002014-01-22T15:08:38.815-08:00Set Tx high (or enable pullup) before the call to ...Set Tx high (or enable pullup) before the call to TxByte. You probably won't have to do it though - the USB-TTL adapter I've tested with doesn't require Tx to be driven high - it only requires it to be pulled low.<br />Ralph Doncasterhttps://www.blogger.com/profile/00037504544742962130noreply@blogger.comtag:blogger.com,1999:blog-6245413346375218188.post-79137047885218455522014-01-20T17:54:36.009-08:002014-01-20T17:54:36.009-08:00Hi Ralph!
"calling code must set Tx line to i...Hi Ralph!<br />"calling code must set Tx line to idle state (high) or 1st byte may be lost"<br /><br />When must be set tx, before or after the call? I´m trying to interrupt drive your rx code without success so far.<br /><br />great work! thanks!Porotitohttps://www.blogger.com/profile/10115175179646525710noreply@blogger.com