Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Reputation Activity

  1. Like
    zborgerd got a reaction from oPossum in MSP-FET Backchannel UART.   
    Just got my half-price MSP-FET in the mail today.  MSP-FET Backchannel UART support was added in MSP Debug Stack  The firmware version and driver versions match this on my system.
    I default my terminal (Linux) to 9600 bps and this is normally fine with the FR5969 and F5529 Launchpad built-in EZ-FET.  However, when I use the MSP-FET on the 5969 LP, I have to bump the speed of the port up to something higher and back down to 9600 before data begins to pass correctly.  Has anyone else observed this?
    Again, the EZ-FET on the same FR5969 LP is fine.  When I switch to the JTAG header with the MSP-FET, the behavior is different.
    There seem to be some differences in the UART behavior on the EZ-FET vs the MSP-FET.
  2. Like
    zborgerd reacted to KatiePier in Could not communicate with FET error = 35   
    My vote goes for the firmware update being needed - there's some more links here with more details: http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/364413/1281328.aspx#1281328
    Some of the Rev 1.4 launchpads will need updates, others won't, depending on how old they are and which firmware they had: http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/97931/364901.aspx
    The fact that he was able to program another part (and I'm guessing the other part was the G2231 that came with the older launchpads even though he just said "G223" in this post) that is a G2xx1 device and so would be programmable without an update. This makes me highly suspect it is just needing the firmware update: http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_Firmware_Update
    The firmware update got implemented when G2xx2 were coming out I believe, but when we did the update we made sure the firmware would support both G2xx2 and G2xx3. So there are 1.4 launchpads that predate G2xx3 that would still have support for it. There are more details in one of the links I put above, from when the firmware update was first being released about which LPs are affected.
  3. Like
    zborgerd reacted to cplc430 in C-Programmable Logic Controller with MSP430   
    A new project based on MSP430 microcontroller is in process of being finalized.
    This is a PLC that can be programmed in C.
    A preliminary description of it can be found at:
    In these days this description will be improved.
    I'll add a bill of materials and a file with C-specific PLC functions.
    The project will be available as a kit from September 15, 2014.

  4. Like
    zborgerd reacted to oPossum in Daylight Saving Time detection and adjustment   
    This code quickly determines if a date is within daylight savings time (DST). A companion function adjusts the date and time if necessary.
    There are many ways to determine if a date is within DST. This code begins by checking large time spans (months) and works down to shorter time spans (hours) as necessary. So for most of the year the decision is made very quickly. The worst cases occur on the days of the transition.
    BCD representation is used for compatibility with most hardware RTC chips. The day of week (T_RTC.dow) must be set properly for this code to work. Day of week is a value of 1 (Sunday) to 8 (Saturday).

    typedef struct { // RTC data structure uint8_t sec; // uint8_t min; // uint8_t hour; // uint8_t dow; // uint8_t day; // uint8_t month; // uint8_t year; // } T_RTC; // // Starting in 2007, most of the United States and Canada observe DST from the second Sunday in March to the first Sunday in November int rtc_is_dst(T_RTC const * const rtc) // --- Check if time & date are within DST { // if((rtc->month > 0x03) && (rtc->month < 0x11)) return 1; // After March and before November is DST if((rtc->month < 0x03) || (rtc->month > 0x11)) return 0; // Before March or after November is not DST if(rtc->month == 0x03) { // March if(rtc->day > 0x15) return 1; // After second week, is DST if(rtc->day < 0x08) return 0; // Before second week, is not DST const int d = ((rtc->day >> 4) * 10) + (rtc->day & 0x0F); // Integer day of month int s = d - rtc->dow + 1; // Current or previous Sunday as day of month if(s < 8) s += 7; // Make sure Sunday is in second week if(d < s) return 0; // Before Sunday, is not DST if(d > s) return 1; // After Sunday, is DST if((rtc->hour & 0x3F) < 0x02) return 0; // Before 2:00, is not DST return 1; // 2:00 or after, is DST } else { // rtc->month == 0x11 // November if(rtc->day > 0x07) return 0; // After first week, not DST const int d = ((rtc->day >> 4) * 10) + (rtc->day & 0x0F); // Integer day of month int s = d - rtc->dow + 1; // Current or previous Sunday as day of month if(s < 0) s += 7; // Make sure Sunday is in first week if(d < s) return 1; // Before Sunday, is DST if(d > s) return 0; // After Sunday, is not DST if((rtc->hour & 0x3F) < 0x02) return 1; // Before 2:00, is DST return 0; // 2:00 or after, is not DST } // } // // void rtc_adjust_dst(T_RTC * const rtc) // --- Correct RTC structure for DST if necessary { // static const uint8_t dm[19] = { 0, 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0, 0, 0, 0, 0, 0, 0x31, 0x30, 0x31 }; if(rtc_is_dst(rtc)) { // If DST ++rtc->hour; // Increment hour if((rtc->hour & 0x0F) > 9) rtc->hour += 6; // Adjust for BCD if(rtc->hour > 0x23) { // If next day rtc->hour = 0; // Set hour to 0 ++rtc->dow; // Increment day of week if(rtc->dow > 7) rtc->dow = 1; // Adjust for wrap around ++rtc->day; // Increment day of month if((rtc->day & 0x0F) > 9) rtc->day += 6; // Adjust for BCD if(rtc->day > dm[rtc->month]) { // Check if next month rtc->day = 0x01; // Wrap to first day of next month ++rtc->month; // Increment month if((rtc->month & 0x0F) > 9) rtc->month += 6; // Adjust for BCD } // } // } // } //
  5. Like
    zborgerd got a reaction from roadrunner84 in GCC for MSP430 officially out of beta   
    So, I've finally tried this in binary form to get it running quickly.  Initial assessment is that the build and packaging is a bit weird.  Interesting that libmsp430 is included, and in the /bin directory, but that's probably for the GDB agent with firmware update capability.  Overall it's organized better than the beta version.  It's a bit less forgiving than MSPGCC was with iinclude files and LD paths, but I guess that's what Makefiles are for.  The included slau591.pdf manual makes it all pretty clear, and it's standard for GCC anyway.
    Seems to compile a few basic examples.  Going to hammer on it a bit more when I get some time.
    There are a few issues with shared library links in some of the included binaries in /bin.  For example, I've found:
    zborgerd@katana:~$ msp430-elf-gdb  msp430-elf-gdb: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory   zborgerd@katana:~$ ldd `which msp430-elf-gdb` | grep libX11 libX11.so.6 => not found   I could manually force the link or redirect it, but I guess the libX11 requirement is simply for an optional GUI component of the GDB agent.  Ditto for wish and some broken tcl components.  I think that someone is going to need to be more careful in packing up these binary builds for end-users, but that's the downside to binaries and shared libraries on lots of different platforms.  
    Beginners should probably stick to MSPGCC for now unless there is an immediate need to upgrade.  For me, I'd like to work on the MSP-EXP430FR5969 launchpad without repeatedly having to BSL a bricked  micro, so this is probably the most logical progression without patching MSPGCC LTS for new FRAM chips.
  6. Like
    zborgerd reacted to colotron in Use mspdebug to upgrade msp430fr5969   
    Ok, I modified slightly the optional sentence
    Nice to know. I did a lot of things before arriving to a valid build of the whole toolchain, due more to my lack of knowledge than the process itself. Hopefully I can save somebody time and nerves
  7. Like
    zborgerd reacted to spirilis in MSP430FR5969 launchpad evaluation kit   
    Fwiw, I have been using the new RedHat GCC in CCSv6 for Wolverine work outside of that which I've done in Energia.  The version of MSPGCC that ships with Energia seems reasonably safe, just limited to <64KB (unless you use a small library I wrote that does DMA copies to/fro the upper 16KB).
  8. Like
    zborgerd got a reaction from greeeg in MSP430FR5969 launchpad evaluation kit   
    So, my MSPGCC is not running any of the patches specified here: http://sourceforge.net/p/mspgcc/mailman/message/29796245/
    There is a very good chance that this is the cause of my problems with having to frequently recover with the BSL.
  9. Like
    zborgerd got a reaction from RobB in Simplest Standalone MSP430G2553 with USB-Serial?   
    This thing works for under $7 shipped.  http://www.amazon.com/gp/product/B009T2ZR6W (CP2102 module).
    You can solder a pad to provide 3.3VCC (defaults to 5V) to power the MSP430.  I used it a few days ago for this task (created a UART without using the Launchpad's built-in lines) on Ubuntu Linux but I hear that the drivers are fine on Linux as well.
    I have two of these.  One is set to the default 5V on VCC and another that I've set to 3.3V. 
  10. Like
    zborgerd got a reaction from Vin255 in We need more posts!   
    Just my personal opinions on the subjects.
    I think that the forums for all three of your TI chip sites should be merged.  I've alays felt that three sites with many of the same userbase makes it more difficult to collaborate.  43oh is a great site and has such a large base, and many projects are shared between all three platforms.  This is especially true since most users work with the various Launchpad parts.  You could still have separate portal sites, if you wish, but the forums should be combined with separate sections for each chip.  For example, AVRFreaks has the AVR8 and 32 products in a single forums.  Some of the stuff, like "Test Equipment Deals" and "Buy / Sell / Trade" are generic.  I tthink that you are already even forwarding some of these to 43oh currently.  But that just requires registration on multiple sites.
    My thoughts:  Giving all 43oh forum members immediate forum access to to posts and info on both of these 32-bit architectures would immediately jumpstart interest in both sites.  Migrate all (non-duplicate) C2kCentral and Stellarisiti users over to 43oh forums, and merge the existing database content for these two sites into new forum sections.  Or, just do the database post content.  There are so many users here that are already on all three sites that it might be easiest to just have people re-register.
    As for the C2000, there is no real incentive right now to use the chip for most projects.  ARM support is very good on all platforms, as is MSP430.  In spite of its benefits, C2000 is a pain to use due to a lack of GNU tools and a mechanism to debug without CCS.  Additionally, just about everyone is only using ARM for 32-bit projects these days.  The C2000 is powerful and has many good applications, but unless it can get a larger userbase, it will probably fade into obscurity in the same way that many other MCU companies are dumping their other 32-bit cores as they migrate to ARM.  Additionally, the C2000 Launchpad is more expensive compared to the other two Launchpads and many of the other ARM low-cost project boards.  Most people have managed to obtain STM32 Discovery boards for free through promos.  We know that the MSP430 Launchpad has always been an outstanding deal.  And the Stellaris Launchpad had great intro pricing in spite of delivery delays.  I've picked up several of each.  I have a Piccolo stick, but haven't felt any desire to pick up a C2000 Launchpad.  By comparison, I love the MSP430 and Stellaris Launchpad boards and work with them often.
    TI contracted Mentor / Code Sourcery to write a GCC port for C6X with GCC 4.7, but support for lower-end TMS320 chips was mysteriously ignored.
    The C2000 Launchpad part is simply not well-positioned for hobbyist projects.  I know that $17.00 is not that much money, but a hobbyist is going to probably pick up the option that is only 1/2 or 1/3 of the price, especially if the other chips are better-supported with example code, and code is generally more portable.  Unless you have a project for motor or power control, the C2000 is probably not the best part for a hobbyist to use.  Higher-end TMS320 chips seem to have better overall support, but even OMAP has been rumored to have a questionable future.
    As an example, I can largely reuse well-established ARM code across both my TI Stellaris and my STM32-based projects with GCC.  Need an RTOS with C2000?  You pretty much have TI RTOS / BIOS.  Need an RTOS for ARM Cortex M4F?  Take your pick.
  11. Like
    zborgerd reacted to spirilis in New $45 Beaglebone   
    Showing off pics of the BeagleBone Sled I got from Craig -- https://www.tindie.com/products/built-to-spec/beaglebone-holder-with-hardware/
    I got mine in clear acrylic, and the "hardware" is just the screws/nuts, standoffs and stick-on feet, not the breadboard.  Bought this for the breadboard- http://www.amazon.com/gp/product/B004RXKWDQ/ref=oh_details_o00_s00_i00?ie=UTF8&psc=1
    It fits well, and the standoffs sit it tall enough to make the microHDMI cable fit perfectly.





  12. Like
    zborgerd reacted to icserny in Renesas Arduino-compatible board   
    I have got recently a promotional GR-Sakura board from Renesas EU. You can apply for one here (if you live in Europe): http://www2.renesas.eu/support_all/registrations/rx_foc_board/index.html
    The most importan think that this board "can be programmed via USB mass storage mode. GR-SAKURA becomes a USB memory drive on your PC when it is plugged. To run your software, just drag and drop the sketch.bin created by Web Compiler." The basic concept behind this is that you don't need to install anything on your computer (you can use even your Android tablet or mobile).
    The board has an Arduino form factor, but it has on board Ethernet and can have USB host function as well. 
    The short description of the board is here: http://sakuraboard.net/gr-sakura_en.html
    Th CPU is a high performance 32-bit RX63N 100-pin R5F563NBDDFP
    Operating frequency: 96 MHz (single precision FPU, on-chip multiplication/division)
    Flash ROM: 1M Bytes, RAM?128K bytes, Data flash?32K bytes The main board features are:
    USB device function (mini-B?or USB host (A) (these are alternatives, so cannot be used at the same time) Download by USB mass storage EtherNet (RJ45) MicroSD jacket (can share data with PC) Arduino compatible sockets Many extra I/O connections Header for the E1 programmer/debugger User forum and community support at: http://renesasrulz.com/?loc=EU (I think it is the same as http://renesasrulz.com/?loc=US)
    But the most interesting information can be found in a separate forum at http://japan.renesasrulz.com/?loc=JP
    These are so much separated that you shoud register yourself separately (so you will have double identity... :-) ) and the links cannot be used directly from one to the other.
    I think the Web compiler principle is a good idea - in theory, but is very slooooow for editing and file handling. Another drawback that uploading and downloading does not work as expected. I quickly had to find a way for offline compiling. I installed the free KPIT GNU toolset since the Web Compiler is using that tools too.
    However, a small modification was necessery in the makefile created by the Web Compiler: I had to add the compiler options: -mgcc-abi -m32bit-doubles
    An example project (a project template) was published here: http://renesasrulz.com/app_kits_and_demo_boards/gadget_renesas_user_forum/m/mediagallery/510.aspx , but is is a bit outdated by now.
    In this (offline) way the project development is much more convenient for me and I am satisfied with the command line compilation.
    Of course, the HEW IDE can be also used: a "no toolchain" (i.e. IDE without the Renesas compiler) vesion of HEW is also avaliable at http://www.kpitgnutools.com/
    which can be combined with the KPIT GNU toolchain. However, I see no any advantage of this solution (i.e. usage of HEW) unless you buy an E1 debugger. If you want to generate a .bin file by HEW, here is the recipe: http://renesasrulz.com/app_kits_and_demo_boards/gadget_renesas_user_forum/w/wiki/260.hew-for-gr-sakura.aspx  (HEW produces .x ELF file, which should be converted to .bin format for the USB flash drive download method.
    If you are interested in my DHT22 project, please see it at http://renesasrulz.com/app_kits_and_demo_boards/gadget_renesas_user_forum/f/128/t/3871.aspx
    This is an adaptation of the Adafruit's DHT library, where the biggest problem was to find the correct timing parameter. The Sakura board is much faster, than Arduino so the "discrimination level" should be 20 and not 6 as in the Arduino library. (I already wrote about this problem in the Energia forum .
    If you are curious (so was I) about the Ethernet capability of the Sakura card then have a look to this project (in Japanese, of course...):
    There is a very simle example (just say Hello in the web browser window) which seems to work. You should add the SPI and Ethernet libraries as well.
    Link: junkroom2cyberrobotics.blogspot.hu/.../arduinogr-sakura-ethernet1.html
    This is a very simple "web server" example (just say Hello in the web browser window). You should add the SPI and Ethernet libraries to your project as well.
    Summarising the thing: the GR-Sakura board is an excellent tool for hobbists. The lack of detailed software documentation and the low number of example projects can be a serious problem for the beginners. I hope that this promotional campaign can gather the critical mass of users which helps to overcome this problem.
    Another major problem that - at present - the libararies are published in precompiled format only. This is a serious drawback and avoids the community development. I think this situation should be changed as soon as possible. Without open source libraries such a development platform cannot be taken seriously (for example I would not let my students to waste their valuable time with such a closed source platform which hides those details from them which they sould have to learn), and cannot compete with other platforms like Arduino, or similar projects.
  13. Like
    zborgerd reacted to TI_Trey in Arduino-like IDE for C2000?   
    I'm excited to say that at 11am Central time today, the first successful build of a C2000 project took place within Energia!

  14. Like
    zborgerd reacted to lalalandrus in MSP430 Router JTAG   
    Playing around with my router and bricked it. Needed a JTAG but most are done with parallel ports. 
    Google search brought me here to this project.
    I ported the code to a MSP430. Changing pinouts should be relatively straight forward in the DEFINES. 
    Note that it uses 115200. The Launchpad application uart only supports 9600. To get 115200, you have to use an external serial cable (i used a FTDI cable). Also, it runs at 16MHz which requires you to do the DCO calibration and modify the msp430 includes to define the 16MHz selection.
    The only downside is that although it works, it is very slow. 
    #include "msp430g2231.h" #include "stdint.h" #include "intrinsics.h" #include "binary.h" //------------------------------------------------------------------------------ // Hardware-related definitions //------------------------------------------------------------------------------ #define UART_TXD BIT1 // TXD on P1.1 (Timer0_A.OUT0) #define UART_RXD BIT2 // RXD on P1.2 (Timer0_A.CCI1A) //------------------------------------------------------------------------------ // Conditions for 9600 Baud SW UART, SMCLK = 1MHz //------------------------------------------------------------------------------ #define UART_TBIT_DIV_2 (16000000 / (115200 * 2)) #define UART_TBIT (16000000 / 115200) //------------------------------------------------------------------------------ // Global variables used for full-duplex UART communication //------------------------------------------------------------------------------ unsigned int txData; // UART internal variable for TX unsigned char rxBuffer[100]; // Received UART character int bytecnt; // Received UART character //------------------------------------------------------------------------------ //JTAG //------------------------------------------------------------------------------ #define WRST_N 7 //BIT0 #define WTMS 5 //BIT3 #define WTCK 6 //BIT4 #define WTDI 3 //BIT6 #define WTRST_N 0 //BIT7 #define WTDO 4 //BIT5 typedef enum __arduOp { OP_RESET = 0, OP_SEND = 1, OP_READ = 2, OP_RSVD = 3 } arduOp; //__no_operation(); //__delay_cycles( 3000 ); //------------------------------------------------------------------------------ // Function prototypes //------------------------------------------------------------------------------ void TimerA_UART_init(void); void TimerA_UART_tx(unsigned char byte); void TimerA_UART_print(char *string); unsigned char serial_getch(void); //------------------------------------------------------------------------------ // main() //------------------------------------------------------------------------------ int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer DCOCTL = 0x00; // Set DCOCLK to 16MHz BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; P1SEL = UART_TXD + UART_RXD; // Timer function for TXD/RXD pins P1DIR = 0xFF & ~UART_RXD & ~(1 << WTDO); // Set all pins but RXD to output P1OUT = 0x00; bytecnt = -1; __enable_interrupt(); TimerA_UART_init(); // Start Timer_A UART TimerA_UART_tx(0x7F); while(1) { static unsigned char temp = 0; static unsigned char byte = 0; byte = serial_getch(); // Wait for incoming character unsigned char op = (byte & B01100000) >> 5 ; switch ( op ) { case OP_RESET: { // Clear all outputs. P1OUT = 0x00; // Respond that we're ready to go. TimerA_UART_tx(0x42); bytecnt = -1; } break; case OP_SEND: { // Set output pins to requested values. temp = 0; temp |= ((byte & B00010000) >> 4 ) << WTRST_N; temp |= ((byte & B00001000) >> 3 ) << WTDI; temp |= ((byte & B00000100) >> 2 ) << WTCK; temp |= ((byte & B00000010) >> 1 ) << WTMS; temp |= ((byte & B00000001) >> 0 ) << WRST_N; P1OUT = temp | (P1OUT & UART_TXD); // If needed: put a TimerA_UART_tx() here so that // we can "wait" for the pins to be set. TimerA_UART_tx(0x4B); } break; case OP_READ: { unsigned char readByte = (P1IN & (1 <<WTDO)) == 0 ? // WTDO B00000000 : // send back a 1 in bit 7 B10000000; // send back a 0 in bit 7 TimerA_UART_tx(readByte); } break; default: { TimerA_UART_tx(0x7F); } }; } } //------------------------------------------------------------------------------ // Function configures Timer_A for full-duplex UART operation //------------------------------------------------------------------------------ void TimerA_UART_init(void) { TACCTL0 = OUT; // Set TXD Idle as Mark = '1' TACCTL1 = SCS + CM1 + CAP + CCIE; // Sync, Neg Edge, Capture, Int TACTL = TASSEL_2 + MC_2; // SMCLK, start in continuous mode } //------------------------------------------------------------------------------ // Outputs one byte using the Timer_A UART //------------------------------------------------------------------------------ void TimerA_UART_tx(unsigned char byte) { while (TACCTL0 & CCIE); // Ensure last char got TX'd TACCR0 = TAR; // Current state of TA counter TACCR0 += UART_TBIT; // One bit time till first bit TACCTL0 = OUTMOD0 + CCIE; // Set TXD on EQU0, Int txData = byte; // Load global variable txData |= 0x100; // Add mark stop bit to TXData txData <<= 1; // Add space start bit } //------------------------------------------------------------------------------ // Prints a string over using the Timer_A UART //------------------------------------------------------------------------------ void TimerA_UART_print(char *string) { while (*string) { TimerA_UART_tx(*string++); } } //------------------------------------------------------------------------------ // serial_getch - wait and return a char //------------------------------------------------------------------------------ unsigned char serial_getch(void) { // Wait for incoming character if (bytecnt < 0) { __bis_SR_register(LPM0_bits);} bytecnt--; // TimerA_UART_tx(rxBuffer[bytecnt+1]); return rxBuffer[bytecnt+1]; } //------------------------------------------------------------------------------ // Timer_A UART - Transmit Interrupt Handler //------------------------------------------------------------------------------ #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A0_ISR(void) { static unsigned char txBitCnt = 10; TACCR0 += UART_TBIT; // Add Offset to CCRx if (txBitCnt == 0) { // All bits TXed? TACCTL0 &= ~CCIE; // All bits TXed, disable interrupt txBitCnt = 10; // Re-load bit counter } else { if (txData & 0x01) { TACCTL0 &= ~OUTMOD2; // TX Mark '1' } else { TACCTL0 |= OUTMOD2; // TX Space '0' } txData >>= 1; txBitCnt--; } } //------------------------------------------------------------------------------ // Timer_A UART - Receive Interrupt Handler //------------------------------------------------------------------------------ #pragma vector = TIMERA1_VECTOR __interrupt void Timer_A1_ISR(void) { static unsigned char rxBitCnt = 8; static unsigned char rxData = 0; switch (TAIV) { // Use calculated branching case TAIV_TACCR1: // TACCR1 CCIFG - UART RX TACCR1 += UART_TBIT; // Add Offset to CCRx if (TACCTL1 & CAP) { // Capture mode = start bit edge TACCTL1 &= ~CAP; // Switch capture to compare mode TACCR1 += UART_TBIT_DIV_2; // Point CCRx to middle of D0 } else { rxData >>= 1; if (TACCTL1 & SCCI) { // Get bit waiting in receive latch rxData |= 0x80; } rxBitCnt--; if (rxBitCnt == 0) { // All bits RXed? rxBuffer[bytecnt+1] = rxData; // Store in global variable bytecnt = ((bytecnt < sizeof(rxBuffer)) ? (bytecnt + 1) : 0); rxBitCnt = 8; // Re-load bit counter TACCTL1 |= CAP; // Switch compare to capture mode __bic_SR_register_on_exit(LPM0_bits); // Clear LPM0 bits from 0(SR) } } break; } } //------------------------------------------------------------------------------ binary.h
    #define B00000000 0x00 #define B00000001 0x01 #define B00000010 0x02 #define B00000011 0x03 #define B00000100 0x04 #define B00000101 0x05 #define B00000110 0x06 #define B00000111 0x07 #define B00001000 0x08 #define B00001001 0x09 #define B00001010 0x0A #define B00001011 0x0B #define B00001100 0x0C #define B00001101 0x0D #define B00001110 0x0E #define B00001111 0x0F #define B00010000 0x10 #define B00010001 0x11 #define B00010010 0x12 #define B00010011 0x13 #define B00010100 0x14 #define B00010101 0x15 #define B00010110 0x16 #define B00010111 0x17 #define B00011000 0x18 #define B00011001 0x19 #define B00011010 0x1A #define B00011011 0x1B #define B00011100 0x1C #define B00011101 0x1D #define B00011110 0x1E #define B00011111 0x1F #define B00100000 0x20 #define B00100001 0x21 #define B00100010 0x22 #define B00100011 0x23 #define B00100100 0x24 #define B00100101 0x25 #define B00100110 0x26 #define B00100111 0x27 #define B00101000 0x28 #define B00101001 0x29 #define B00101010 0x2A #define B00101011 0x2B #define B00101100 0x2C #define B00101101 0x2D #define B00101110 0x2E #define B00101111 0x2F #define B00110000 0x30 #define B00110001 0x31 #define B00110010 0x32 #define B00110011 0x33 #define B00110100 0x34 #define B00110101 0x35 #define B00110110 0x36 #define B00110111 0x37 #define B00111000 0x38 #define B00111001 0x39 #define B00111010 0x3A #define B00111011 0x3B #define B00111100 0x3C #define B00111101 0x3D #define B00111110 0x3E #define B00111111 0x3F #define B01000000 0x40 #define B01000001 0x41 #define B01000010 0x42 #define B01000011 0x43 #define B01000100 0x44 #define B01000101 0x45 #define B01000110 0x46 #define B01000111 0x47 #define B01001000 0x48 #define B01001001 0x49 #define B01001010 0x4A #define B01001011 0x4B #define B01001100 0x4C #define B01001101 0x4D #define B01001110 0x4E #define B01001111 0x4F #define B01010000 0x50 #define B01010001 0x51 #define B01010010 0x52 #define B01010011 0x53 #define B01010100 0x54 #define B01010101 0x55 #define B01010110 0x56 #define B01010111 0x57 #define B01011000 0x58 #define B01011001 0x59 #define B01011010 0x5A #define B01011011 0x5B #define B01011100 0x5C #define B01011101 0x5D #define B01011110 0x5E #define B01011111 0x5F #define B01100000 0x60 #define B01100001 0x61 #define B01100010 0x62 #define B01100011 0x63 #define B01100100 0x64 #define B01100101 0x65 #define B01100110 0x66 #define B01100111 0x67 #define B01101000 0x68 #define B01101001 0x69 #define B01101010 0x6A #define B01101011 0x6B #define B01101100 0x6C #define B01101101 0x6D #define B01101110 0x6E #define B01101111 0x6F #define B01110000 0x70 #define B01110001 0x71 #define B01110010 0x72 #define B01110011 0x73 #define B01110100 0x74 #define B01110101 0x75 #define B01110110 0x76 #define B01110111 0x77 #define B01111000 0x78 #define B01111001 0x79 #define B01111010 0x7A #define B01111011 0x7B #define B01111100 0x7C #define B01111101 0x7D #define B01111110 0x7E #define B01111111 0x7F #define B10000000 0x80 #define B10000001 0x81 #define B10000010 0x82 #define B10000011 0x83 #define B10000100 0x84 #define B10000101 0x85 #define B10000110 0x86 #define B10000111 0x87 #define B10001000 0x88 #define B10001001 0x89 #define B10001010 0x8A #define B10001011 0x8B #define B10001100 0x8C #define B10001101 0x8D #define B10001110 0x8E #define B10001111 0x8F #define B10010000 0x90 #define B10010001 0x91 #define B10010010 0x92 #define B10010011 0x93 #define B10010100 0x94 #define B10010101 0x95 #define B10010110 0x96 #define B10010111 0x97 #define B10011000 0x98 #define B10011001 0x99 #define B10011010 0x9A #define B10011011 0x9B #define B10011100 0x9C #define B10011101 0x9D #define B10011110 0x9E #define B10011111 0x9F #define B10100000 0xA0 #define B10100001 0xA1 #define B10100010 0xA2 #define B10100011 0xA3 #define B10100100 0xA4 #define B10100101 0xA5 #define B10100110 0xA6 #define B10100111 0xA7 #define B10101000 0xA8 #define B10101001 0xA9 #define B10101010 0xAA #define B10101011 0xAB #define B10101100 0xAC #define B10101101 0xAD #define B10101110 0xAE #define B10101111 0xAF #define B10110000 0xB0 #define B10110001 0xB1 #define B10110010 0xB2 #define B10110011 0xB3 #define B10110100 0xB4 #define B10110101 0xB5 #define B10110110 0xB6 #define B10110111 0xB7 #define B10111000 0xB8 #define B10111001 0xB9 #define B10111010 0xBA #define B10111011 0xBB #define B10111100 0xBC #define B10111101 0xBD #define B10111110 0xBE #define B10111111 0xBF #define B11000000 0xC0 #define B11000001 0xC1 #define B11000010 0xC2 #define B11000011 0xC3 #define B11000100 0xC4 #define B11000101 0xC5 #define B11000110 0xC6 #define B11000111 0xC7 #define B11001000 0xC8 #define B11001001 0xC9 #define B11001010 0xCA #define B11001011 0xCB #define B11001100 0xCC #define B11001101 0xCD #define B11001110 0xCE #define B11001111 0xCF #define B11010000 0xD0 #define B11010001 0xD1 #define B11010010 0xD2 #define B11010011 0xD3 #define B11010100 0xD4 #define B11010101 0xD5 #define B11010110 0xD6 #define B11010111 0xD7 #define B11011000 0xD8 #define B11011001 0xD9 #define B11011010 0xDA #define B11011011 0xDB #define B11011100 0xDC #define B11011101 0xDD #define B11011110 0xDE #define B11011111 0xDF #define B11100000 0xE0 #define B11100001 0xE1 #define B11100010 0xE2 #define B11100011 0xE3 #define B11100100 0xE4 #define B11100101 0xE5 #define B11100110 0xE6 #define B11100111 0xE7 #define B11101000 0xE8 #define B11101001 0xE9 #define B11101010 0xEA #define B11101011 0xEB #define B11101100 0xEC #define B11101101 0xED #define B11101110 0xEE #define B11101111 0xEF #define B11110000 0xF0 #define B11110001 0xF1 #define B11110010 0xF2 #define B11110011 0xF3 #define B11110100 0xF4 #define B11110101 0xF5 #define B11110110 0xF6 #define B11110111 0xF7 #define B11111000 0xF8 #define B11111001 0xF9 #define B11111010 0xFA #define B11111011 0xFB #define B11111100 0xFC #define B11111101 0xFD #define B11111110 0xFE #define B11111111 0xFF

  15. Like
    zborgerd got a reaction from Rickta59 in My time with the Renesas RX   
    This is what I was saying to Trey in the C2K Forums, almost jokingly, regarding a Raspberry Pi and a C2000.  But it seems that there is a real application for this.  You can do something like this because you have GCC for the RX and Linux on the Beaglebone.  No such luck for the poor C2K.
    This is a good way to gain valuable I/O and peripherals from a simple uC when paired with an ARM chip that runs a powerful OS.  And it's cool that all of the build and debug could be handled on the Beaglebone directly.
  16. Like
    zborgerd got a reaction from spirilis in My time with the Renesas RX   
    Very cool!  Your FreeRTOS code compiles fine on Linux with KPIT's compiler.  I had been using that other 6.1 version of FreeRTOS for a while and will give this a shot.  Unfortunately, I have to nail down my problem with Ubuntu's uhci_hcd driver.  My workaround of using a hub is out of the question now, since my external hard drive enclosure failed, so I removed the drive and installed it in my PC.  Until then, I can't use rxflash.
  17. Like
    zborgerd got a reaction from spirilis in My time with the Renesas RX   
    This is what I was saying to Trey in the C2K Forums, almost jokingly, regarding a Raspberry Pi and a C2000.  But it seems that there is a real application for this.  You can do something like this because you have GCC for the RX and Linux on the Beaglebone.  No such luck for the poor C2K.
    This is a good way to gain valuable I/O and peripherals from a simple uC when paired with an ARM chip that runs a powerful OS.  And it's cool that all of the build and debug could be handled on the Beaglebone directly.
  18. Like
    zborgerd reacted to spirilis in My time with the Renesas RX   
    I am totally working on a build of rx-elf-gcc on the BeagleBone Black, BTW
    Imagine that, develop rx on your 'bone, talk to its application over CAN...
  19. Like
    zborgerd reacted to spirilis in New $45 Beaglebone   
    New tip:
    If you'd like to use Screen, to persist shell sessions across logins/etc (get some long process started and then come back to it later from another workstation/another location/etc) you must add a config option to dropbear's service config so it won't nuke all your processes (including SCREEN processes) when you logout.
    Add "KillMode=process" to the end of /lib/systemd/system/dropbear@.service (note the @ sign in there) and reboot.
  20. Like
    zborgerd got a reaction from oPossum in New $45 Beaglebone   
    The new Beaglebone is pretty slick.  I can see plenty of applications where it is better than the Raspberry Pi, at a comparable price (considering that the Pi really needs an SD card AND a USB drive to be truly useful).
    That said, as much as the Pi gets crtisicism for being ARM11 (v6), the core makes up for it with the hardware decoders.  Raspberry Pi works very well for media centers, especially when overclocked, and especially with the inexpensive optional hardware decoder keys.  I use mine with Raspbmc and really like it.  I doubt that the new Beaglebone would be as suitable for such a task, considering that the uC is really intended for industrial automation.  But it would really excel at projects that can make use of the peripherals.
    It's amazing how much power you can get in these little inexpensive computers.
  21. Like
    zborgerd reacted to spirilis in My time with the Renesas RX   
    Sitting in a coffeehouse taking a break from the kids and home for an hour (my wife hates me, LOL), I got FreeRTOS working on the RX210.  
    Used the RX100 "port" code, which seems to have an odd bug; they named the vTickISR "vPortTickISR" and vSoftwareInterruptISR "vPortSoftwareInterruptISR" which has no references anywhere else, so building FreeRTOS resulted in the linker complaining about no _vTickISR and _vSoftwareInterruptISR functions.  So I renamed them back to the standard vTickISR and vSoftwareInterruptISR in RX100/port.c and that compiled fine.
    Just got 2 tasks that blink LEDs at slightly variable rates, equal to 250ms + port bit ID * 20 (e.g. P1.5 = portbit 5, P1.6 = portbit 6), using vTaskDelay() to have the scheduler do the suspension & delay implementation.
    #include "iodefine.h" #include <stdlib.h> #include <stdint.h> #include <FreeRTOS.h> #include <FreeRTOSConfig.h> #include <task.h> #include <queue.h> #include <printf-stdarg.h> static void task_LEDp1(void *); // LED blinker for PORT1 /* Relocatable Interrupt Vector Table--including it here */ typedef void (*Interrupt_Handler)(void); extern Interrupt_Handler _vectors[256]; /* FreeRTOS port ISRs */ extern void vTickISR( void ); extern void vSoftwareInterruptISR( void ); int main() { // crt0.S has us running at 50MHz out the door // Configure interrupt vectors for FreeRTOS tick & SWINT _vectors[VECT(CMT0,CMI0)] = vTickISR; _vectors[VECT(ICU,SWINT)] = vSoftwareInterruptISR; xTaskCreate(task_LEDp1, (const signed char*) "LED1", 240, (void*) 6, 2, NULL); // P1.6 xTaskCreate(task_LEDp1, (const signed char*) "LED2", 240, (void*) 5, 2, NULL); // P1.5 vTaskStartScheduler(); while(1) ; // Infinite loop indicating we're fucked! } void vApplicationSetupTimerInterrupt() { /* Enable compare match timer 0. */ MSTP( CMT0 ) = 0; /* Interrupt on compare match. */ CMT0.CMCR.BIT.CMIE = 1; /* Set the compare match value. */ CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 ); /* Divide the PCLK by 8. */ CMT0.CMCR.BIT.CKS = 0; /* Enable the interrupt... */ IEN( CMT0,CMI0 ) = 1; /* ...and set its priority to the application defined kernel priority. */ IPR( CMT0,CMI0 ) = configKERNEL_INTERRUPT_PRIORITY; /* Start the timer. */ CMT.CMSTR0.BIT.STR0 = 1; } void vApplicationMallocFailedHook( void ) { while(1) ; } static void task_LEDp1(void *pvParameters) { unsigned int portbit = (unsigned int)pvParameters; PORT1.PMR.BYTE &= ~(1 << portbit); PORT1.PDR.BYTE |= 1 << portbit; PORT1.PODR.BYTE |= 1 << portbit; while (1) { PORT1.PODR.BYTE ^= (1 << portbit); vTaskDelay( (250+portbit*20) / portTICK_RATE_MS ); } } Might take this "freertos-bare" dir I have and put it up on github soon.
  22. Like
    zborgerd reacted to spirilis in My time with the Renesas RX   
    I have FreeRTOS running now!  Not just the silly demo that you have to use HEW in Windows to import either.  After reading through the FreeRTOS book (RX600 edition) and getting a handle on the barebones that you need to get a FreeRTOS project going I have one together, doing one of the example tasks they list in the book.
    This basically has the FreeRTOSConfig.h in the main dir along with main.c, rx62n8.ld (linker script) and Makefile.  iodefine.h is also there.
    FreeRTOS's base files and include .h's, along with the "portable" dir with RX-specific crap, is in the FreeRTOS/ dir.
    FreeRTOSConfig.h is spartan with all the profiling crap turned off for simplicity sake.  Got the timer set up for 20Hz tick and it uses the CMT0 "Compare Match Timer" for the timer tick (the default for all FreeRTOS RX-based ports).
    Main.c is interesting, here's what it looks like:
    #include "iodefine.h" #include <stdlib.h> #include <stdint.h> #include <okaya.h> #include <FreeRTOS.h> #include <FreeRTOSConfig.h> #include <task.h> #include <queue.h> #include <printf-stdarg.h> xQueueHandle xQueue; static void vReceiverTask(void *); static void vSenderTask(void *); /* Relocatable Interrupt Vector Table--including it here */ typedef void (*Interrupt_Handler)(void); extern Interrupt_Handler _vectors[256]; /* FreeRTOS port ISRs */ extern void vTickISR( void ); extern void vSoftwareInterruptISR( void ); int main() { SYSTEM.SCKCR.BIT.ICK = 0x00; // ICLK = 96MHz SYSTEM.SCKCR.BIT.PCK = 0x02; // PCLK = 24MHz SYSTEM.SCKCR.BIT.PSTOP1 = 1; SYSTEM.SCKCR.BIT.PSTOP0 = 1; MSTP(RSPI0) = 0; okaya_init(); st7579_backlight(1); // Configure interrupt vectors for FreeRTOS tick & SWINT _vectors[VECT(CMT0,CMI0)] = vTickISR; _vectors[VECT(ICU,SWINT)] = vSoftwareInterruptISR; xQueue = xQueueCreate(5, sizeof(long)); if (xQueue != NULL) { xTaskCreate(vSenderTask, (const signed char*) "Sender1", 240, (void*)100, 1, NULL); xTaskCreate(vSenderTask, (const signed char*) "Sender2", 240, (void*)200, 1, NULL); xTaskCreate(vReceiverTask, (const signed char*) "Receiver", 240, NULL, 2, NULL); vTaskStartScheduler(); } while(1) ; // Infinite loop indicating we're fucked! } void vApplicationSetupTimerInterrupt() { /* Enable compare match timer 0. */ MSTP( CMT0 ) = 0; /* Interrupt on compare match. */ CMT0.CMCR.BIT.CMIE = 1; /* Set the compare match value. */ CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 ); /* Divide the PCLK by 8. */ CMT0.CMCR.BIT.CKS = 0; /* Enable the interrupt... */ IEN( CMT0,CMI0 ) = 1; /* ...and set its priority to the application defined kernel priority. */ IPR( CMT0,CMI0 ) = configKERNEL_INTERRUPT_PRIORITY; /* Start the timer. */ CMT.CMSTR0.BIT.STR0 = 1; } void vApplicationMallocFailedHook( void ) { while(1) ; } static void vSenderTask(void *pvParameters) { long lValueToSend; portBASE_TYPE xStatus; lValueToSend = (long) pvParameters; while (1) { xStatus = xQueueSendToBack(xQueue, &lValueToSend, 0); if (xStatus != pdPASS) { taskENTER_CRITICAL(); okaya_puts("Could not send to the queue.\n"); taskEXIT_CRITICAL(); } taskYIELD(); } } static void vReceiverTask(void *pvParameters) { long lReceivedValue; portBASE_TYPE xStatus; const portTickType xTicksToWait = 100 / portTICK_RATE_MS; char stbuf[64]; while (1) { if (uxQueueMessagesWaiting(xQueue) != 0) { taskENTER_CRITICAL(); okaya_puts("Queue should have been empty!\n"); taskEXIT_CRITICAL(); } xStatus = xQueueReceive(xQueue, &lReceivedValue, xTicksToWait); if (xStatus == pdPASS) { taskENTER_CRITICAL(); sprintf(stbuf, "Received = %ld\n", lReceivedValue); okaya_puts(stbuf); taskEXIT_CRITICAL(); } else { taskENTER_CRITICAL(); okaya_puts("Could not receive from the queue.\n"); taskEXIT_CRITICAL(); } } } Since I'm using my special "pure Newlib/GCC" setup, I have to manually set the interrupt vector assignments for its TickISR and software interrupt ISR.  The receiver task is using a critical section to perform its RSPI output to the Okaya LCD so it doesn't get interrupted in the middle.  Near future task I need to get on is finding and/or writing a suitable RSPI task-oriented driver that doesn't require critical sections and can act as a queue-oriented service for building other SPI-dependent device drivers.
    Also included the RX100 port, which is new, but should basically support the RX200 series too.  It just ignores the floating point crap.  I liked reading the context switch ASM code (RX600 port here)-
    void vSoftwareInterruptISR( void ) { __asm volatile ( /* Re-enable interrupts. */ "SETPSW I \n" \ /* Move the data that was automatically pushed onto the interrupt stack when the interrupt occurred from the interrupt stack to the user stack. R15 is saved before it is clobbered. */ "PUSH.L R15 \n" \ /* Read the user stack pointer. */ "MVFC USP, R15 \n" \ /* Move the address down to the data being moved. */ "SUB #12, R15 \n" \ "MVTC R15, USP \n" \ /* Copy the data across, R15, then PC, then PSW. */ "MOV.L [ R0 ], [ R15 ] \n" \ "MOV.L 4[ R0 ], 4[ R15 ] \n" \ "MOV.L 8[ R0 ], 8[ R15 ] \n" \ /* Move the interrupt stack pointer to its new correct position. */ "ADD #12, R0 \n" \ /* All the rest of the registers are saved directly to the user stack. */ "SETPSW U \n" \ /* Save the rest of the general registers (R15 has been saved already). */ "PUSHM R1-R14 \n" \ /* Save the FPSW and accumulator. */ "MVFC FPSW, R15 \n" \ "PUSH.L R15 \n" \ "MVFACHI R15 \n" \ "PUSH.L R15 \n" \ /* Middle word. */ "MVFACMI R15 \n" \ /* Shifted left as it is restored to the low order word. */ "SHLL #16, R15 \n" \ "PUSH.L R15 \n" \ /* Save the stack pointer to the TCB. */ "MOV.L #_pxCurrentTCB, R15 \n" \ "MOV.L [ R15 ], R15 \n" \ "MOV.L R0, [ R15 ] \n" \ /* Ensure the interrupt mask is set to the syscall priority while the kernel structures are being accessed. */ "MVTIPL %0 \n" \ /* Select the next task to run. */ "BSR.A _vTaskSwitchContext \n" \ /* Reset the interrupt mask as no more data structure access is required. */ "MVTIPL %1 \n" \ /* Load the stack pointer of the task that is now selected as the Running state task from its TCB. */ "MOV.L #_pxCurrentTCB,R15 \n" \ "MOV.L [ R15 ], R15 \n" \ "MOV.L [ R15 ], R0 \n" \ /* Restore the context of the new task. The PSW (Program Status Word) and PC will be popped by the RTE instruction. */ "POP R15 \n" \ "MVTACLO R15 \n" \ "POP R15 \n" \ "MVTACHI R15 \n" \ "POP R15 \n" \ "MVTC R15, FPSW \n" \ "POPM R1-R15 \n" \ "RTE \n" \ "NOP \n" \ "NOP " :: "i"(configMAX_SYSCALL_INTERRUPT_PRIORITY), "i"(configKERNEL_INTERRUPT_PRIORITY) ); }
  23. Like
    zborgerd reacted to vinodstanur in stellaris video player (25 fps with audio, 320x140 resolution)   
    Hi, here is my new mad project, a small video player which plays uncompressed video file stored in as sd card. It can play 25fps video at 320x140 resolution with audio... Color depth is 16bit/pixel.


    It plays a special format, my own uncompressed video format, the only disadvantage is it will take more memory in sd card compared to compressed formats...



    Source code is open....
  24. Like
    zborgerd reacted to spirilis in My time with the Renesas RX   
    Morning hack:  HSV to RGB conversion, now my RX62N is deriving a Hue degrees setting from the potentiometer onboard, setting Saturation and Value to 1.0, converting to RGB and sending the new value to my water jug lamp.
    /* Floating-point HSV to RGB conversion */ #include <math.h> #include <stdint.h> uint32_t HSV_to_RGB(float h, float s, float v) { int i; float f, p, q, t; float r, g, b; uint32_t rgb; if (s == 0.0) { // Achromatic (grey) r = g = b = v; } else { // Chromatic h /= 60.0; i = floorf(h); f = h - i; p = v * (1 - s); q = v * (1 - s*f); t = v * (1 - s * (1 - f)); switch(i) { case 0: r = v; g = t; b = p; break; case 1: r = q; g = v; b = p; break; case 2: r = p; g = v; b = t; break; case 3: r = p; g = q; b = v; break; case 4: r = t; g = p; b = v; break; default: // case 5 r = v; g = p; b = q; break; } } rgb = (uint32_t) (r * 255.0) << 16; rgb |= (uint32_t) (g * 255.0) << 8; rgb |= (uint32_t) (b * 127.0); return rgb; }  
    Program to update the water jug over nRF24L01+ (using my "nrfdmx" code adapted from MSP430)
    /* RDK Color Changer * * Utilizes Nordic nRF24L01+ with DMX512 adapter protocol to change the colors of a lamp nearby */ #include "iodefine.h" #include <rxrf24.h> #include <okaya.h> #include "packet_processor.h" #include "dmx512.h" #include "misc.h" #include "hsv2rgb.h" #include <stdlib.h> #include <string.h> #include <stdint.h> /* Relocatable Interrupt Vector Table--including it here */ typedef void (*Interrupt_Handler)(void); extern Interrupt_Handler _vectors[256]; /* SW1/2/3 button press IRQ handler */ //void pushbutton_handler() __attribute__((interrupt)); //volatile uint8_t button_press; void puthex(uint32_t); float hue_rotate(float, float); /* CSN, CE pin configuration for Nordic transceiver */ void csn_init(uint8_t onoff) { PORTC.DDR.BIT.B1 = onoff; PORTC.DR.BIT.B1 = 0; } void csn_set(uint8_t onoff) { PORTC.DR.BIT.B1 = onoff; } void ce_init(uint8_t onoff) { PORTE.DDR.BIT.B4 = onoff; PORTE.DR.BIT.B4 = 0; } void ce_set(uint8_t onoff) { PORTE.DR.BIT.B4 = onoff; } const uint8_t dmxuniverse_addr[] = { 0xDE, 0xAD, 0xDE, 0xED, 0x01 }; const uint8_t dmxstartcode = 0x00; const uint8_t colorschemes[6][3] = { { 0xFF, 0x00, 0x00 }, { 0x00, 0xFF, 0x00 }, { 0x00, 0x00, 0x7F }, { 0xFF, 0xFF, 0x00 }, { 0x00, 0xFF, 0x7F }, { 0xFF, 0x00, 0x7F } }; const uint8_t colorschemes_len = 6; int main() { //uint8_t curpos = 0; uint8_t do_sleep, do_conversion=1; uint32_t i=0, rgb; float s = 1.0, v = 1.0; SYSTEM.SCKCR.BIT.ICK = 0x00; // ICLK = 96MHz SYSTEM.SCKCR.BIT.PCK = 0x02; // PCLK = 24MHz SYSTEM.SCKCR.BIT.PSTOP1 = 1; SYSTEM.SCKCR.BIT.PSTOP0 = 1; MSTP(RSPI1) = 0; PORT2.DDR.BIT.B1 = 1; PORT2.DR.BIT.B1 = 0; // Shut off that distracting LCD backlight PORTD.DDR.BIT.B2 = 1; // Debug LED PORTD.DR.BIT.B2 = 1; // nRF24L01+ settings nrf24.address_width = 5; nrf24.channel = 10; nrf24.speed = 250000; nrf24.crc.BIT.en = 1; nrf24.crc.BIT.crc16 = 1; nrf24.chipselect_init = csn_init; nrf24.chipselect = csn_set; nrf24.chipenable_init = ce_init; nrf24.chipenable = ce_set; okaya_init(); st7579_backlight(0); dmx512_init(); rxrf24_init(); // RXaddr rxrf24_open_pipe(0, 0); // Open pipe#1 for reading with autoack=0 rxrf24_set_pipe_packetsize(0, 0); // Pipe#1 packet size = 0 (DYNAMIC) // Initialize IRQ13 to respond to incoming nRF24 IRQ requests _vectors[VECT_ICU_IRQ13] = rxrf24_irq_handler; PORT0.DDR.BIT.B5 = 0; // P05 = input PORT0.ICR.BIT.B5 = 1; // P05 input schmitt-trigger enabled ICU.IRQCR[13].BIT.IRQMD = 1; // Configure GPIO IRQ for Falling Edge /* FYI- values include 0 (level-triggered LOW) * 1 (falling-edge) * 2 (rising edge) * 3 (rising and falling edges) */ IR(ICU,IRQ13) = 0; // Clear IRQ in case it's set IPR(ICU,IRQ13) = 1; // Priority = 1 IEN(ICU,IRQ13) = 1; // Enable /* Initialize SW1, SW2, SW3 * SW1 = P40 (IRQ8) * SW2 = P41 (IRQ9) * SW3 = P42 (IRQ10) */ /* _vectors[VECT_ICU_IRQ8] = pushbutton_handler; _vectors[VECT_ICU_IRQ9] = pushbutton_handler; _vectors[VECT_ICU_IRQ10] = pushbutton_handler; PORT4.DDR.BYTE &= ~0x07; PORT4.ICR.BYTE |= 0x07; ICU.IRQCR[8].BIT.IRQMD = 1; ICU.IRQCR[9].BIT.IRQMD = 1; ICU.IRQCR[10].BIT.IRQMD = 1; IR(ICU,IRQ8) = 0; IR(ICU, IRQ9) = 0; IR(ICU, IRQ10) = 0; IPR(ICU,IRQ8) = 1; IPR(ICU, IRQ9) = 1; IPR(ICU, IRQ10) = 1; button_press = 0; IEN(ICU,IRQ8) = 1; IEN(ICU, IRQ9) = 1; IEN(ICU, IRQ10) = 1; */ __builtin_rx_setpsw(8); // Enable Interrupts /* Initialize AN004 potentiometer */ MSTP(AD1) = 0; MSTP(S12AD) = 1; MSTP(AD0) = 1; PORT4.DDR.BIT.B4 = 0; PORT4.ICR.BIT.B4 = 0; AD1.ADCSR.BIT.CH = 0x00; // AN004 AD1.ADCSR.BIT.ADIE = 0; // No interrupts AD1.ADCR.BIT.CKS = 0x03; // Clock = PCLK/1 AD1.ADCR.BIT.MODE = 0x00; // Single-conversion mode AD1.ADCR.BIT.TRGS = 0x00; // Software-trigger AD1.ADDPR.BIT.DPSEL = 0; // Right-aligned data AD1.ADDIAGR.BIT.DIAG = 0; // No diagnostics okaya_puts("nRF24L01+ initialized.\n"); while (1) { do_sleep = 1; if (nrf24.irq.BIT.flag) { //okaya_puts("nrf24 irq\n"); rxrf24_get_irq_reason(); if (nrf24.irq.BIT.rx) { rxrf24_flush_rx(); rxrf24_irq_clear(nrf24.irq.BYTE); okaya_puts("nrf24: RX\n"); } if (nrf24.irq.BIT.tx || nrf24.irq.BIT.txfailed) { rxrf24_irq_clear(nrf24.irq.BYTE); rxrf24_flush_tx(); okaya_puts("nrf24: TX\n"); do_conversion = 1; } do_sleep = 0; } /* if (button_press) { if (button_press & 0x01) { // SW1 if (curpos) curpos--; else curpos = 5; } if (button_press & 0x02) { // SW2 memcpy(dmx512_buffer, colorschemes[curpos], 3); dmx512_output_channels(dmxstartcode, 1, dmx512_buffer, 3); okaya_puts("color_commit\n"); } if (button_press & 0x04) { // SW3 curpos += 1; curpos %= colorschemes_len; } button_press = 0; okaya_puts("curpos="); puthex(curpos); okaya_puts("\n"); } */ if (do_conversion) { do_conversion = 0; AD1.ADCSR.BIT.ADST = 1; // Start ADC conversion while (AD1.ADCSR.BIT.ADST) ; rgb = HSV_to_RGB( (float)AD1.ADDRA / 2.849, s, v ); rgb = __builtin_bswap32(rgb) >> 8; // make it suitable for memcpy() memcpy(dmx512_buffer, &rgb, 3); dmx512_output_channels(dmxstartcode, 1, dmx512_buffer, 3); //okaya_puts("update "); puthex(__builtin_bswap32(rgb) << 8); okaya_putc('\n', 1); } if (packet_task_next() != NULL) { //okaya_puts("txpkt process\n"); packet_process_txqueue(); } if (do_sleep) { i++; // RX600 light sleep mode } } return 0; } /* void pushbutton_handler() // Defined as Interrupt up above { button_press = ~(PORT4.PORT.BYTE & 0x07) & 0x07; } */ const uint8_t hexdigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; void puthex(uint32_t hex) { int8_t i; uint8_t val; for (i=7; i >= 0; i--) { val = (hex >> i*4) & 0x0F; okaya_putc(hexdigits[val], 0); } }
  25. Like
    zborgerd got a reaction from spirilis in If we judge all those Arduino clones out there by cuteness, this one surely will win   
    I still think that the GR Sakura tops just about anything out there:  http://www.renesas.com/products/promotion/gr/index.jsp
    Don't be fooled by the pink exterior.  It's very powerful.  Pobably on-par with the Cortex M4F.  Maybe more powerful in some respects.  http://www.renesas.eu/products/mpumcu/rx/rx600/rx63n_631/device/R5F563NBDDFP.jsp

  • Create New...