In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote: Bob, Problem #1: _bank is a marco that is declared somewhere at the beginning of the source code like this: ; For SX18/20/28 change FSR bits 7...5, ; for SX48/52 change FSR bits 6...4 ; _bank macro 1 bank \1 IFDEF SX48_52 ; For SX48/52 change IF \1 & %10000000 ; FSR bit 7 setb fsr.7 ELSE clrb fsr.7 ENDIF ENDIF endm It makes sure that FSR bit 7 is correctly set for SX48/52 devices as the bank instruction does not modify bit 7. When you use the SX 28, you don't need the macro, and simply change "_bank" into "bank". Problem #2: UARTfs = 230400 is the sample frequency, it defines how often the UART input pins are sampled per second. With a clock frequency of 50 MHz, and an interrupt period of 217, UARTfs is 50 MHz / 217 = 230.4 kHz or 230400 Hz. Num = 4 - Yes, you are right, this means that the UART code is called every fourth interrupt call. Int Period = 217 - Yes, this means that the interrupt is fired every 217th clock cycle. UARTDivide1 = UARTfs/(UARTbaud1*Num) - Yes, this calculates the number of executions of the UART transmit code for one bit length. UARTStDelay1=UARTDivide1 + (UARTDivide1/2)+1 - After the receiver has detected a start bit, it requires a 1.5 bit time delay to "hit" the first received data bit "in the middle". After the first bit has been read, a delay time of just UARTDivide1 is required to "hit" the next bits "in the middle". To set the Baud rates to 2400, use the following definitions: UARTDivide1 = UARTfs/(2400*Num) UARTDivide2 = UARTfs/(2400*Num) This would set the UARTS to 2400-8-N-1 BTW: This UART code example is pretty complex - you can find another example in my SX book, and you may download the book code samples from here: [url]http://www.parallax.com/Portals/0/Downloads/src/prod/sx/ProgSXEdPre.zip[/url] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=231026#m231110 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)