|
|
View previous topic :: View next topic |
Author |
Message |
Adrian Cable
Joined: 12 Aug 2004 Posts: 1
|
Undocumented compiler features: RTOS, RS232 software UART |
Posted: Thu Oct 14, 2004 3:14 pm |
|
|
Hello,
It's come to my attention that the CCS compiler (at least my version, 3.190) supports a large number of undocumented functions and options. Some are pretty useful, e.g. there's some cool stuff with #use rs232. For example, many times it's been asked how to define a software UART on the same pins as the hardware UART. Many kludges have been proposed, but the easiest way is just to use the undocumented force_sw flag:
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,force_sw)
Multi-master mode for I2C:
#use i2c(multi_master,sda=XXX,scl=XXX,force_hw)
Plus, there is #use rtos(rtos_run=XXX, rtos_yield=XXX, rtos_terminate=XXX) and a corresponding #task - I haven't been able to figure out how to use these.
Does anyone have any further info on these features?
-A |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Oct 14, 2004 5:14 pm |
|
|
The RS232 and I2C stuff is in the help file:
Quote: |
#USE RS232
Syntax:
#use rs232 (options)
Elements:
Options are separated by commas and may be:
STREAM=id
Associates a stream identifier with this RS232 port. The identifier may then be used in functions like fputc.
BAUD=x
Set baud rate to x
XMIT=pin
Set transmit pin
RCV=pin
Set receive pin
FORCE_SW
Will generate software serial I/O routines even when the UART pins are specified.
BRGH1OK
Allow bad baud rates on chips that have baud rate problems.
DEBUGGER
Indicates this stream is used to send/receive data though a CCS ICD unit. The default pin used in B3, use XMIT= and RCV= to change the pin used. Both should be the same pin.
RESTART_WDT
Will cause GETC() to clear the WDT as it waits for a character.
INVERT
Invert the polarity of the serial pins (normally not needed when level converter, such as the MAX232). May not be used with the internal UART.
PARITY=X
Where x is N, E, or O.
BITS =X
Where x is 5-9 (5-7 may not be used with the SCI).
FLOAT_HIGH
The line is not driven high. This is used for open collector outputs. Bit 6 in RS232_ERRORS is set if the pin is not high at the end of the bit time.
ERRORS
Used to cause the compiler to keep receive errors in the variable RS232_ERRORS and to reset errors when they occur.
SAMPLE_EARLY
A getc() normally samples data in the middle of a bit time. This option causes the sample to be at the start of a bit time. May not be used with the UART.
RETURN=pin
For FLOAT_HIGH and MULTI_MASTER this is the pin used to read the signal back. The default for FLOAT_HIGH is the XMIT pin and for MULTI_MASTER the RCV pin.
MULTI_MASTER
Uses the RETURN pin to determine if another master on the bus is transmitting at the same time. If a collision is detected bit 6 is set in RS232_ERRORS and all future PUTC's are ignored until bit 6 is cleared. The signal is checked at the start and end of a bit time. May not be used with the UART.
LONG_DATA
Makes getc() return an int16 and putc accept an int16. This is for 9 bit data formats.
DISABLE_INTS
Will cause interrupts to be disabled when the routines get or put a character. This prevents character distortion for software implemented I/O and prevents interaction between I/O in interrupt handlers and the main program when using the UART.
Purpose:
This directive tells the compiler the baud rate and pins used for serial I/O. This directive takes effect until another RS232 directive is encountered. The #USE DELAY directive must appear before this directive can be used. This directive enables use of built-in functions such as GETC, PUTC, and PRINTF.
When using parts with built-in SCI and the SCI pins are specified, the SCI will be used. If a baud rate cannot be achieved within 3% of the desired value using the current clock rate, an error will be generated. The definition of the RS232_ERRORS is as follows:
No UART:
· Bit 7 is 9th bit for 9 bit data mode (get and put).
· Bit 6 set to one indicates a put failed in float high mode.
With a UART:
· Used only by get:
· Copy of RCSTA register except:
· Bit 0 is used to indicate a parity error.
Examples:
#use rs232(baud=9600, xmit=PIN_A2,rcv=PIN_A3)
Example Files:
ex_sqw.c
Also See:
getc(), putc(), printf()
|
Quote: |
#USE I2C
Syntax:
#use i2c (options)
Elements:
Options are separated by commas and may be:
MASTER
Set the master mode
SLAVE
Set the slave mode
SCL=pin
Specifies the SCL pin (pin is a bit address)
SDA=pin
Specifies the SDA pin
ADDRESS=nn
Specifies the slave mode address
FAST
Use the fast I2C specification
SLOW
Use the slow I2C specification
RESTART_WDT
Restart the WDT while waiting in I2C_READ
FORCE_HW
Use hardware I2C functions.
NOFLOAT_HIGH
Does not allow signals to float high, signals are driven from low to high
SMBUS
Bus used is not I2C bus, but very similar
Purpose:
The I2C library contains functions to implement an I2C bus. The #USE I2C remains in effect for the I2C_START, I2C_STOP, I2C_READ, I2C_WRITE and I2C_POLL functions until another USE I2C is encountered. Software functions are generated unless the FORCE_HW is specified. The SLAVE mode should only be used with the built-in SSP.
Examples:
#use I2C(master, sda=PIN_B0, scl=PIN_B1)
#use I2C(slave,sda=PIN_C4,scl=PIN_C3
address=0xa0,FORCE_HW)
Example Files:
ex_extee.c with 2464.c
Also See:
i2c_read(), i2c_write()
|
|
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Thu Oct 14, 2004 5:33 pm |
|
|
Strange...my help file does not mention any of these:
Quote: |
FORCE_SW
Will generate software serial I/O routines even when the UART pins are specified.
SAMPLE_EARLY
A getc() normally samples data in the middle of a bit time. This option causes the sample to be at the start of a bit time. May not be used with the UART.
RETURN=pin
For FLOAT_HIGH and MULTI_MASTER this is the pin used to read the signal back. The default for FLOAT_HIGH is the XMIT pin and for MULTI_MASTER the RCV pin.
MULTI_MASTER
Uses the RETURN pin to determine if another master on the bus is transmitting at the same time. If a collision is detected bit 6 is set in RS232_ERRORS and all future PUTC's are ignored until bit 6 is cleared. The signal is checked at the start and end of a bit time. May not be used with the UART.
LONG_DATA
Makes getc() return an int16 and putc accept an int16. This is for 9 bit data formats.
DISABLE_INTS
Will cause interrupts to be disabled when the routines get or put a character. This prevents character distortion for software implemented I/O and prevents interaction between I/O in interrupt handlers and the main program when using the UART.
|
Readme.txt doesn't mention FORCE_SW (but it explains the rest). I wasn't aware this features existed.
It seems the have finally updated their help file. I am using PCWH 3.190, IDE version 3.46.
Quote: |
Plus, there is #use rtos(rtos_run=XXX, rtos_yield=XXX, rtos_terminate=XXX) and a corresponding #task - I haven't been able to figure out how to use these.
|
This is still in beta:
http://www.ccsinfo.com/news.shtml |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|