Last evening I found my function for SPI1 not working, because MOSI1 was not sending anything out. This morning I googled CooCox SPI1 and found Jean Pierre reported the bug some 2 years ago, but CooCox seems not updating that and still distributes the oild 2010 version. I fixed the bug as suggested by Jean and everything runs smoothly now.
* @file : lpc11xx_wdt.h
* @brief : Contains all macro definitions and function prototypes support for WDT firmware library on LPC11xx
* @version : 1.0
* @date : 22. Jan. 2010
* @author : Coocox
// *** old ***
// #define PIO2_3_FUN_PIO_MOSI1 0 /** Selects function PIO */
// #define PIO2_3_FUN_RI 1
// *** new ***
#define PIO2_3_FUN_PIO 0 // Selects function PIO
#define PIO2_3_FUN_RI 1
#define PIO2_3_FUN_PIO_MOSI1 2 // Select MOSI1 tlfong01 2013oct27
// *** Reference ***
// http://www.coocox.org/forum/topic.php?id=645
*** MCP3208 Test - 2013oct27hk0948 ***
*** Tx Rx buffer contents before ADC ***
Index 0 1 2
TxBuf 06 80 00
RxBuf 00 00 00
*** Tx Rx buffer contents after ADC ***
Index 0 1 2
TxBuf 06 80 00
RxBuf ff ea 8b
***ADC Results Summary ***
SPI Channel = 1
ADC Channel = 2
ADC result hex = a8b
ADC result decimal = 2699
ADC result milliVolt = 1640
*** End of Test. ***
Bug found in LPC111x library: Non-working SPI1 peripheral (includes solution) - Jean-Pierre
http://www.coocox.org/forum/topic.php?id=645
2 years ago
Hi CooCox!
I found a bug in your latest LPC111x library. SPI1 was unworkable, and after much testing I was able to find your IOCON definition for MOSI1 was different than the NXP datasheet.
Fixing your lpc11xx_iocon.h to the code belows makes SPI1 functional.
//***MOD: Bug found that makes SPI1 peripheral unworkable. The values here should match
table 89 (section 7.4.34) of NXP LPC111x user manual (page 83)
#define PIO2_3_FUN_PIO 0 /** Selects function PIO */
#define PIO2_3_FUN_RI 1
#define PIO2_3_FUN_PIO_MOSI1 2 // (Should be named PIO2_3_FUN_MOSI1 instead)
// Old (incorrect) values below
//#define PIO2_3_FUN_PIO_MOSI1 0 /** Selects function PIO */
//#define PIO2_3_FUN_RI 1
(Please look at other definitions in ioconf.h to make sure they match. Possibly other chips in the family could be affected as well)
Congrats on the great work!
Jean-Pierre
Sandy 2 years ago
Hi, JPPoulin:
Thanks for your feedback, we will modify the component as you said. If you find any problems in the CooCox Components, you can tell me, and we will modify them.
Thanks for your support!
.END
No comments:
Post a Comment