Reply
Highlighted
Posts: 267
Registered: ‎03-14-2014
Accepted Solution

Blinky example for C8051F996-TB Problems

[ Edited ]

Hi

I am using a C8051F996-TB board to do a review from a beginners perspective, after my stroke my memory has had it and I have forgotten just about everything I had learnt about the sil labs 8051. This is kind of a cool chance to go back to square one and really see what its like as total newb again.

So I borrowed the above board and decided to start at square one with what is normally the most simple program used to get beginners started, what a shambles! Utter disappointment and waste of time. First I have no idea what version of sim studio I am using, I went to help and the about screen which is kinda common place where you would expect to find such info but no, not in this case. For some completely unfathomable reason it has been decided to not follow the normal convention and place the info here, no problem I will go search the hard drive and look at the version number on the package.............Oh dear its not on the file description!

Never mind lets just update the software and carry on, so I have updated the software which took ages.

I loaded the blinky example and first thing I notice is a warning at line number 47 (#include "InitDevice.h") saying something cryptic about not finding address within 5 source lines of break point! WTF I dont to my knowledge at this point have a break point, but its just a warning so with unease I decide to ignore it.

Now to get to my problem and deep niggle, the program is meant to flash a led roughly 5 times a second.

Normally blink led programs are there for people new to a platform to get an idea of how to get things up and running, they are not meant to be a place for some smart A@@e to show off his coding skills.

I wanted to change the rate of flashing, not to anything in particular but just to get playing with the code and start building it up to do something useful.

What do I find in main file? The following

 

//-----------------------------------------------------------------------------
// F99x_Blinky.c
//-----------------------------------------------------------------------------
// Copyright 2014 Silicon Laboratories, Inc.
// http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
//
// Program Description:
//
// This program flashes the yellow LED on the C8051F996 target board about
// five times a second using the interrupt handler for Timer2.
//
//
// How To Test:
//
// 1) Ensure that jumpers are placed on the following:
//       J8:   P1.3/LED1.3
//       J11:  PWR/WALL_PWR
//       J17:  VDD_PIN/PWR
// 2) Connect the USB Debug Adapter to J4.
// 3) Turn the POWER switch (SW5) to the "ON" position.
// 4) Compile and download code to a 'F99x device on a C8051F99x-TB development
//    board by selecting Run -> Debug from the menus, clicking the Debug button
//    in the quick menu, or pressing F11.
// 5) Run the code by selecting Run -> Resume from the menus, clicking the
//    Resume button in the quick menu, or pressing F8.
// 6) If the Yellow LED flashes, the program is working.
//
//
// Target:         C8051F99x-C8051F98x
// Tool chain:     Simplicity Studio / Keil C51 9.51
// Command Line:   None
//
// Release 1.1 (BL)
//    - Updated Description / How to Test
//    - 13 JAN 2014
//
// Release 1.0
//    - Initial Revision (FB)
//    - 19 MAY 2010
//

//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <compiler_defs.h>
#include <SI_C8051F990_Register_Enums.h>                  // SFR declarations
#include "InitDevice.h"

//-----------------------------------------------------------------------------
// Global VARIABLES
//-----------------------------------------------------------------------------
LOCATED_VARIABLE_NO_INIT (reserved, U8, SEG_XDATA, 0x0000);

//-----------------------------------------------------------------------------
// main() Routine
// ----------------------------------------------------------------------------
int main (void)
{
	//Enter default mode

	enter_DefaultMode_from_RESET();

	while (1) {}                             // Spin forever

	// NOTREACHED
	return 0;
}

 Just about nothing in main of any use to change the rate of flashing, a single function that to be honest tells me little

enter_DefaultMode_from_RESET();

 So I assume at this point the place to change the rate of flashing will be in here, after all this is code designed to give newcomers a start point right? Surely you wouldnt put more than one layer of code between the main and the place where you alter the main point of the code?? So I go looking at the declaration of this function and find the following file

//=========================================================
// src/InitDevice.c: generated by Hardware Configurator
//
// This file will be regenerated when saving a document.
// leave the sections inside the "$[...]" comment tags alone
// or they will be overwritten!
//=========================================================

// USER INCLUDES
#include <SI_C8051F990_Register_Enums.h>
#include "InitDevice.h"

// USER PROTOTYPES
// USER FUNCTIONS


//==============================================================================
// enter_DefaultMode_from_RESET
//==============================================================================
extern void enter_DefaultMode_from_RESET(void) {
	// $[Config Calls]
	PCA_0_enter_DefaultMode_from_RESET();
	PORTS_1_enter_DefaultMode_from_RESET();
	PBCFG_0_enter_DefaultMode_from_RESET();
	CLOCK_0_enter_DefaultMode_from_RESET();
	TIMER16_2_enter_DefaultMode_from_RESET();
	TIMER_SETUP_0_enter_DefaultMode_from_RESET();
	INTERRUPT_0_enter_DefaultMode_from_RESET();
	// [Config Calls]$


}


//================================================================================
// PCA_0_enter_DefaultMode_from_RESET
//================================================================================
extern void PCA_0_enter_DefaultMode_from_RESET(void) {
	// $[Watchdog Disable]
	// Stop Watchdog
	// If MCU is reset by WDT before it runs to main(), please disable it in SILABS_STARTUP.A51
	SFRPAGE = 0x00;
	PCA0MD &= ~PCA0MD_WDTE__BMASK;

	// [Watchdog Disable]$

	// $[PCA0CPM0 - PCA Channel 0 Capture/Compare Mode 0]
	// [PCA0CPM0 - PCA Channel 0 Capture/Compare Mode 0]$

	// $[PCA0CPL0 - PCA Channel 0 Capture Module Low Byte]
	// [PCA0CPL0 - PCA Channel 0 Capture Module Low Byte]$

	// $[PCA0CPH0 - PCA Channel 0 Capture Module High Byte]
	// [PCA0CPH0 - PCA Channel 0 Capture Module High Byte]$

	// $[PCA0CPM1 - PCA Channel 1 Capture/Compare Mode]
	// [PCA0CPM1 - PCA Channel 1 Capture/Compare Mode]$

	// $[PCA0CPL1 - PCA Channel 1 Capture Module Low Byte]
	// [PCA0CPL1 - PCA Channel 1 Capture Module Low Byte]$

	// $[PCA0CPH1 - PCA Channel 1 Capture Module High Byte]
	// [PCA0CPH1 - PCA Channel 1 Capture Module High Byte]$

	// $[PCA0CPM2 - PCA Channel 2 Capture/Compare Mode]
	// [PCA0CPM2 - PCA Channel 2 Capture/Compare Mode]$

	// $[PCA0CPL2 - PCA Channel 2 Capture Module Low Byte]
	// [PCA0CPL2 - PCA Channel 2 Capture Module Low Byte]$

	// $[PCA0CPH2 - PCA Channel 2 Capture Module High Byte]
	// [PCA0CPH2 - PCA Channel 2 Capture Module High Byte]$

	// $[PCA0CN - PCA Control]
	// [PCA0CN - PCA Control]$

	// $[PCA0L - PCA Counter/Timer Low Byte]
	// [PCA0L - PCA Counter/Timer Low Byte]$

	// $[PCA0H - PCA Counter/Timer High Byte]
	// [PCA0H - PCA Counter/Timer High Byte]$

	// $[PCA0PWM - PCA PWM Configuration]
	// [PCA0PWM - PCA PWM Configuration]$

	// $[PCA0MD - PCA Mode]
	// [PCA0MD - PCA Mode]$

	// $[WDT - Watchdog run Control]
	// [WDT - Watchdog run Control]$


}

//================================================================================
// PORTS_1_enter_DefaultMode_from_RESET
//================================================================================
extern void PORTS_1_enter_DefaultMode_from_RESET(void) {
	// $[P1 - Port 1 Pin Latch]
	// [P1 - Port 1 Pin Latch]$

	// $[P1MDOUT - Port 1 Output Mode]
	/*
	// B0 (Port 1 Bit 0 Output Mode) = OPEN_DRAIN (P1.0 output is open-
	//     drain.)
	// B1 (Port 1 Bit 1 Output Mode) = OPEN_DRAIN (P1.1 output is open-
	//     drain.)
	// B2 (Port 1 Bit 2 Output Mode) = OPEN_DRAIN (P1.2 output is open-
	//     drain.)
	// B3 (Port 1 Bit 3 Output Mode) = PUSH_PULL (P1.3 output is push-pull.)
	// B4 (Port 1 Bit 4 Output Mode) = OPEN_DRAIN (P1.4 output is open-
	//     drain.)
	// B5 (Port 1 Bit 5 Output Mode) = PUSH_PULL (P1.5 output is push-pull.)
	// B6 (Port 1 Bit 6 Output Mode) = OPEN_DRAIN (P1.6 output is open-
	//     drain.)
	// B7 (Port 1 Bit 7 Output Mode) = OPEN_DRAIN (P1.7 output is open-
	//     drain.)
	*/
	P1MDOUT = P1MDOUT_B0__OPEN_DRAIN | P1MDOUT_B1__OPEN_DRAIN | P1MDOUT_B2__OPEN_DRAIN
		 | P1MDOUT_B3__PUSH_PULL | P1MDOUT_B4__OPEN_DRAIN | P1MDOUT_B5__PUSH_PULL
		 | P1MDOUT_B6__OPEN_DRAIN | P1MDOUT_B7__OPEN_DRAIN;
	// [P1MDOUT - Port 1 Output Mode]$

	// $[P1MDIN - Port 1 Input Mode]
	// [P1MDIN - Port 1 Input Mode]$

	// $[P1SKIP - Port 1 Skip]
	// [P1SKIP - Port 1 Skip]$

	// $[P1MASK - Port 1 Mask]
	// [P1MASK - Port 1 Mask]$

	// $[P1MAT - Port 1 Match]
	// [P1MAT - Port 1 Match]$

	// $[P1DRV - Port 1 Drive Strength]
	// [P1DRV - Port 1 Drive Strength]$


}

//================================================================================
// PBCFG_0_enter_DefaultMode_from_RESET
//================================================================================
extern void PBCFG_0_enter_DefaultMode_from_RESET(void) {
	// $[XBR2 - Port I/O Crossbar 2]
	/*
	// WEAKPUD (Port I/O Weak Pullup Disable) = PULL_UPS_ENABLED (Weak
	//     Pullups enabled (except for Ports whose I/O are configured for analog
	//     mode).)
	// XBARE (Crossbar Enable) = ENABLED (Crossbar enabled.)
	*/
	XBR2 = XBR2_WEAKPUD__PULL_UPS_ENABLED | XBR2_XBARE__ENABLED;
	// [XBR2 - Port I/O Crossbar 2]$

	// $[XBR0 - Port I/O Crossbar 0]
	// [XBR0 - Port I/O Crossbar 0]$

	// $[XBR1 - Port I/O Crossbar 1]
	// [XBR1 - Port I/O Crossbar 1]$


}

//================================================================================
// CLOCK_0_enter_DefaultMode_from_RESET
//================================================================================
extern void CLOCK_0_enter_DefaultMode_from_RESET(void) {
	// $[CLKSEL - Clock Select]
	// [CLKSEL - Clock Select]$


}

//================================================================================
// TIMER16_2_enter_DefaultMode_from_RESET
//================================================================================
extern void TIMER16_2_enter_DefaultMode_from_RESET(void) {
	// $[Timer Initialization]
	// Save Timer Configuration
	U8 TMR2CN_TR2_save = TMR2CN & TMR2CN_TR2__BMASK;
	// Stop Timer
	TMR2CN &= ~(TMR2CN_TR2__BMASK);
	// [Timer Initialization]$

	// $[TMR2CN - Timer 2 Control]
	// [TMR2CN - Timer 2 Control]$

	// $[TMR2H - Timer 2 High Byte]
	/*
	// TMR2H (Timer 2 High Byte) = 255
	*/
	TMR2H = (255 << TMR2H_TMR2H__SHIFT);
	// [TMR2H - Timer 2 High Byte]$

	// $[TMR2L - Timer 2 Low Byte]
	/*
	// TMR2L (Timer 2 Low Byte) = 255
	*/
	TMR2L = (255 << TMR2L_TMR2L__SHIFT);
	// [TMR2L - Timer 2 Low Byte]$

	// $[TMR2RLH - Timer 2 Reload High Byte]
	/*
	// TMR2RLH (Timer 2 Reload High Byte) = 174
	*/
	TMR2RLH = (174 << TMR2RLH_TMR2RLH__SHIFT);
	// [TMR2RLH - Timer 2 Reload High Byte]$

	// $[TMR2RLL - Timer 2 Reload Low Byte]
	/*
	// TMR2RLL (Timer 2 Reload Low Byte) = 159
	*/
	TMR2RLL = (159 << TMR2RLL_TMR2RLL__SHIFT);
	// [TMR2RLL - Timer 2 Reload Low Byte]$

	// $[TMR2CN]
	/*
	// TR2 (Timer 2 Run Control) = RUN (Start Timer 2 running.)
	*/
	TMR2CN |= TMR2CN_TR2__RUN;
	// [TMR2CN]$

	// $[Timer Restoration]
	// Restore Timer Configuration
	TMR2CN |= TMR2CN_TR2_save;
	// [Timer Restoration]$


}

//================================================================================
// TIMER_SETUP_0_enter_DefaultMode_from_RESET
//================================================================================
extern void TIMER_SETUP_0_enter_DefaultMode_from_RESET(void) {
	// $[CKCON - Clock Control]
	// [CKCON - Clock Control]$

	// $[TMOD - Timer 0/1 Mode]
	// [TMOD - Timer 0/1 Mode]$

	// $[TCON - Timer 0/1 Control]
	// [TCON - Timer 0/1 Control]$


}

//================================================================================
// INTERRUPT_0_enter_DefaultMode_from_RESET
//================================================================================
extern void INTERRUPT_0_enter_DefaultMode_from_RESET(void) {
	// $[EIE1 - Extended Interrupt Enable 1]
	// [EIE1 - Extended Interrupt Enable 1]$

	// $[EIP1 - Extended Interrupt Priority 1]
	// [EIP1 - Extended Interrupt Priority 1]$

	// $[IE - Interrupt Enable]
	/*
	// EA (All Interrupts Enable) = ENABLED (Enable each interrupt according
	//     to its individual mask setting.)
	// EX0 (External Interrupt 0 Enable) = DISABLED (Disable external
	//     interrupt 0.)
	// EX1 (External Interrupt 1 Enable) = DISABLED (Disable external
	//     interrupt 1.)
	// ESPI0 (SPI0 Interrupt Enable) = DISABLED (Disable all SPI0
	//     interrupts.)
	// ET0 (Timer 0 Interrupt Enable) = DISABLED (Disable all Timer 0
	//     interrupt.)
	// ET1 (Timer 1 Interrupt Enable) = DISABLED (Disable all Timer 1
	//     interrupt.)
	// ET2 (Timer 2 Interrupt Enable) = ENABLED (Enable interrupt requests
	//     generated by the TF2L or TF2H flags.)
	// ES0 (UART0 Interrupt Enable) = DISABLED (Disable UART0 interrupt.)
	*/
	IE = IE_EA__ENABLED | IE_EX0__DISABLED | IE_EX1__DISABLED | IE_ESPI0__DISABLED
		 | IE_ET0__DISABLED | IE_ET1__DISABLED | IE_ET2__ENABLED | IE_ES0__DISABLED;
	// [IE - Interrupt Enable]$

	// $[IP - Interrupt Priority]
	// [IP - Interrupt Priority]$

	// $[EIE2 - Extended Interrupt Enable 2]
	// [EIE2 - Extended Interrupt Enable 2]$

	// $[EIP2 - Extended Interrupt Priority 2]
	// [EIP2 - Extended Interrupt Priority 2]$


}


 I assume in there is the place I need to alter the timer and get the LED blinking at a different rate? But I am a beginner and the comments tell me nothing about what I need to change, there is no explanation as to what actually is responsible for the flash rate.

Ok the code is elegant and clearly written by someone who knows C code well, but it fails completely at being a nice easy starting point for a beginner. Its too clever and too convoluted for someone starting out to get there heads around, why not put a comment in telling you THIS IS THE LINE FOR THE RATE OF FLASHING or something like that. At least then I have a start point.

 

Anyway this sounds like a rant but it isnt, I am trying to convey the frustration encountered by a beginner who dosnt want to look stupid but is made to feel so because they have to ask how to make something so simple work.

So my questions are

1) what do I alter to change the rate of flashing

2) Is it a good idea to be a smart A@@e with simple code normally aimed at people starting out

3) Any chance you can alter the comments to give a beginner a fighting chance when starting to learn C

4) Would it be better to use a more simple program to flash a LED with the code that actually alters the flash rate contained in the main program

5) Where do I find the VER number for Sim Studio and why dosnt it follow normal convention of putting that info on the about page??

 

Yes I know this is all very easy if you understand C well, I was reasonable at C but I am back at the start. Seeing this through the eyes of a beginners make me realize people quickly forget what its like when you first start learning a platform or language.

Now while this experience will be in my review I am confident the brownie points will be made back up by a timely response to my questions, that way I can explain that things go wrong but what matters is how they are put right. Silicon Labs excels at doing that so please dont let me down Robot Very Happy

 

Best Regards

LG

Posts: 140
Registered: ‎10-26-2011

Re: Blinky example for C8051F996-TB Problems

LG11

 

I totally agree with you.

You can check the blinky example for C8051F330 or some other mature devices. They have much better structure and easier to play with.

 

For your information, the 174 and 159 values in F996 code sets the blink rate with no documentation or calculation at all, and it is a very bad programming style to load a 16bit value using decimal equivalent of high byte and low byte.

 

Again I recommend to switch to C8051F330 examples.

 

MHG

Posts: 3,153
Registered: ‎02-07-2002

Re: Blinky example for C8051F996-TB Problems


hossein wrote:

I totally agree with you.


And so do I.

Posts: 267
Registered: ‎03-14-2014

Re: Blinky example for C8051F996-TB Problems

Hi

Thanks a lot for the info, I wasnt having a go but like to point things out as a newb see's them. I will switch over as suggested but lucky enough its starting to slowly come back to me, even though my own code is generally poorly commented I still hate reading badly commented code. Hopefully someone will listen and see there is little point writing blinky code for experienced programmers!! The whole point of a blinky program is to help beginners get the hang of a platform not show off your 3kill3 as a HAXOR or whatever its called Man Tongue

Posts: 8,176
Registered: ‎08-13-2003

Re: Blinky example for C8051F996-TB Problems

Hopefully someone will listen and see there is little point writing blinky code for experienced programmers!!

au contraire, when downloading a set of tools (e.g. simplicity Studio) the first thing I do is to run a simple example to verify the installation and functionality of the tools

erik
Posts: 267
Registered: ‎03-14-2014

Re: Blinky example for C8051F996-TB Problems

Ok so there is a reason to have a blinky program for experienced and lazy Robot Very Happy, but my point still holds.

Posts: 8,176
Registered: ‎08-13-2003

Re: Blinky example for C8051F996-TB Problems

experienced and lazy :robotvery-happy:,

 

no offence, but you are wrong.  The reason to check a new installation with e.g. 'blinky' is not laziness, but the experienced principle  "keep the number of unknowns down to the absolute minimum"

erik
Posts: 267
Registered: ‎03-14-2014

Re: Blinky example for C8051F996-TB Problems

Hi erik, I was pulling your leg. Actually the more I think about what you said the more worse it looks. Now it looks like blinky type code is added to help experienced people in the way you mention, therefore clearly newbs are actively discouraged from using the software.

Taking you as an example using it to test a new set up, then it looks like the code is done that way so beginners dont understand it, of course that would be stupidity and I doubt sil labs would of done it intentionally. Everybody has to start somewhere and for many people they will stick with what they first learn or know best. In alot of ways its upto people like me to point these things out otherwise there would be no reason to think anything was wrong.

I wasnt bitching as such but trying to get a feeling across as to how it can be frustrating, it wouldnt stop me from learning as I am used to you and the others and therefore know how easy it is to get quality help, I would be interested to hear the official opinion on it. Anyway sorry for pulling your leg I didnt mean to imply you sat around all day answering questions on forums Robot tongue (only jokeing...... AGAIN)

 

LG

Posts: 8,176
Registered: ‎08-13-2003

Re: Blinky example for C8051F996-TB Problems

as said before no offence.  However what comes out of this is "dual purpose".  I gives a means of quickchecking an install for those that have no need/desire to peruse the code and an opportunity to peruse code for those that have such a need.  Thus, for the first all it needs is to work, for the second it needs be understandable.  The sacond does not oblitterate the first

erik
Posts: 488
Registered: ‎02-21-2014

Re: Blinky example for C8051F996-TB Problems

This example was actually converted to use the new config tool, Configurator, which generates all of the initialization code, which is why it looks so unreadable. If you open up the associated .hwconf file, things should make a bit more sense.

 

Anyway, if you want to see the old blinky example, here it is:

 

//-----------------------------------------------------------------------------
// F99x_Blinky.c
//-----------------------------------------------------------------------------
// Copyright (C) 2010 Silicon Laboratories, Inc.
// http://www.silabs.com
//
// Program Description:
//
// This program flashes the yellow LED on the C8051F990 target board about
// five times a second using the interrupt handler for Timer2.
//
//
// How To Test:
//
// 1) Download code to the 'F99x target board
// 2) Ensure that pins 3 and 4 are shorted together on the J8 header
// 3) Run the program.  If the Yellow LED flashes, the program is working
//
//
// Target:         C8051F99x-C8051F98x
// Tool chain:     Generic
// Command Line:   None
//
// Release 1.0
//    - Initial Revision (FB)
//    - 19 MAY 2010
//

//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <compiler_defs.h>             // compiler declarations
#include <C8051F990_defs.h>            // SFR declarations

//-----------------------------------------------------------------------------
// Pin Declarations
//-----------------------------------------------------------------------------

SBIT (RED_LED,    SFR_P1, 5);          // '0' means ON, '1' means OFF
SBIT (YELLOW_LED, SFR_P1, 3);          // '0' means ON, '1' means OFF
SBIT (SW2,        SFR_P0, 2);          // SW2 == 0 means switch pressed
SBIT (SW3,        SFR_P0, 3);          // SW3 == 0 means switch pressed

//-----------------------------------------------------------------------------
// Global CONSTANTS
//-----------------------------------------------------------------------------

#define SYSCLK       20000000/8        // SYSCLK frequency in Hz

#define LED_ON           0
#define LED_OFF          1

//-----------------------------------------------------------------------------
// Global VARIABLES
//-----------------------------------------------------------------------------
LOCATED_VARIABLE_NO_INIT (reserved, U8, SEG_XDATA, 0x0000);

//-----------------------------------------------------------------------------
// Function PROTOTYPES
//-----------------------------------------------------------------------------
void PORT_Init (void);
void Timer2_Init (int counts);

//-----------------------------------------------------------------------------
// MAIN Routine
//-----------------------------------------------------------------------------
void main (void)
{
   PCA0MD &= ~0x40;                    // WDTE = 0 (clear watchdog timer
                                       // enable)
   PORT_Init ();

   Timer2_Init (SYSCLK / 12 / 10);     // Init Timer2 to generate interrupts
                                       // at a 10 Hz rate.

   EA = 1;                             // Enable global interrupts

   while (1) {}                        // Spin forever
}

//-----------------------------------------------------------------------------
// PORT_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// This function configures the crossbar and ports pins.
//
// P0.2   digital   open-drain    Switch 2
// P0.3   digital   open-drain    Switch 3
// P1.5   digital   push-pull     Red LED
// P1.3   digital   push-pull     Yellow LED
//-----------------------------------------------------------------------------
void PORT_Init (void)
{
   P0MDIN |= 0x0C;                     // P0.2, P0.3 are digital
   P1MDIN |= 0x28;                     // P1.5, P1.3 are digital

   P0MDOUT &= ~0x0C;                   // P0.2, P0.3 are open-drain
   P1MDOUT |= 0x28;                    // P1.5, P1.3 are push-pull

   P0     |= 0x0C;                     // Set P0.2, P0.3 latches to '1'

   XBR2    = 0x40;                     // Enable crossbar and enable
                                       // weak pull-ups
}

//-----------------------------------------------------------------------------
// Timer2_Init
//-----------------------------------------------------------------------------
//
// Configure Timer2 to 16-bit auto-reload and generate an interrupt at
// interval specified by <counts> using SYSCLK/48 as its time base.
//
void Timer2_Init (int counts)
{
   TMR2CN  = 0x00;                        // Stop Timer2; Clear TF2;
                                          // use SYSCLK/12 as timebase
   CKCON  &= ~0x60;                       // Timer2 clocked based on T2XCLK;

   TMR2RL  = -counts;                     // Init reload values
   TMR2    = 0xffff;                      // set to reload immediately
   ET2     = 1;                           // enable Timer2 interrupts
   TR2     = 1;                           // start Timer2
}

//-----------------------------------------------------------------------------
// Interrupt Service Routines
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Timer2_ISR
//-----------------------------------------------------------------------------
// This routine changes the state of the LED whenever Timer2 overflows.
//
INTERRUPT(Timer2_ISR, INTERRUPT_TIMER2)
{
   TF2H = 0;                              // clear Timer2 interrupt flag
   YELLOW_LED = !YELLOW_LED;              // change state of LEDs
}

//-----------------------------------------------------------------------------
// End Of File
//-----------------------------------------------------------------------------

 

Posts: 267
Registered: ‎03-14-2014

Re: Blinky example for C8051F996-TB Problems

Hi

For beginners the old one is alot more use, OR in the MAIN file put a comment that details where to find something that makes sense Robot Very Happy.

I am kind of torn with the configurator as I can see how its useful, but when learning I can see it getting in the way. Personally I prefer the old file, thanks for posting it.

LG

Posts: 8,176
Registered: ‎08-13-2003

Re: Blinky example for C8051F996-TB Problems

Configurator, which generates all of the initialization code, which is why it looks so unreadable.

 

 

OOPS! while config and config2 have had, looking at the complexity, remarkably few bugs, there has been enough to create the rule "by all means use config, but, at the slighest suspicion, verify".  I doubt any tool covering the myriad of devices can ever be bug free.  THUS the resukt should be easily readable.

erik
Posts: 488
Registered: ‎02-21-2014

Re: Blinky example for C8051F996-TB Problems


erikm wrote:

 

 "by all means use config, but, at the slighest suspicion, verify".


In Configurator's defense, the generated code is probably optimal for that purpose - it describes what every bit in every register that gets set does, as well as its generated setting. It is generally "unreadable" from an application perspective, though, since it's just a series of register sets, and has no knowledge of any application specifics.

 

I'm open to suggestions, though, on how to make it more readable, if you have any.

 

-Brian

Posts: 140
Registered: ‎10-26-2011

Re: Blinky example for C8051F996-TB Problems


BrianL wrote:

It is generally "unreadable" from an application perspective, though, since it's just a series of register sets, and has no knowledge of any application specifics.
-Brian

Why generating an "Unreadable" C code? Isn't it easier (and probably more efficient) to generate assembly code if readability is not a concern?

 

At least you can address the tool that generated this code, like:

/* Atomatically generated by Silabs Configurator Vxx.xx */

 

 

Other suggestions for Configurator:

  1. In Configurator software, you can add some symbol to graphical view of pins to indicate the pin mode (i.e Open Collector, Push-pull, Analog).
  2. The Right click on a pin in graphical view shall have some option to set mode.
  3. Skipped pins have the same graphical attribute as unassigned pins
  4. "Mode Transition" is not required for most of applications, it is better to be enabled by user. The first Tab in Configurator is a feature rarely used by most of users.

MHG

 

 

Posts: 267
Registered: ‎03-14-2014

Re: Blinky example for C8051F996-TB Problems

when I posted this it was because I am in the process of doing some kit reviews, I tried the blinky and wanted to build upon it to get a feel for the kit. My assumption at the beginning was there would be an easy fix, but now reading the replies I realize the solution is not as easy as I thought.

First off putting something in a comment on the file that explains it has been generated by the configurator is a good idea. But changing the configurator seems a bit pointless, from a beginners view point the configurator is a great tool, the code from it however is no good to learn from, so maybe the simple approach is better in this case........ Keep the configurator as it is, but install some simple blinky type programs in simplicity studio that have been written by real people not a software program, for the likes of Erik I dont think it matters if the code is done by a programmer or a program, what erik and the other cool people need is simple code to verify a set up.

A beginner however needs code that they can get an idea how things are done, we can work alot of the details out on our own but we need a start point, take the original code posted from the old program, it actually explains a great deal in a very short number of lines of code.

So in an ideal world I would say keep the configurator as it is with maybe a comment at the top of the file explaining how the code was generated, but make sure you dont isolate beginners by not including a couple of simple programs they can follow, these should be done by people not software.

It wouldnt matter so much if your university page was upto the job, but lets be fair its basic and was done with little interest in doing it (thats the impression it gives), its a shame because silicon labs actually has a forward thinking approach to teaching, they are one of the few companies really thinking ahead to when I and my generation will be in the driving seat and making the buying decisions. ok that could be 10-20 years time, but you dont plant an acorn expecting wood in the morning (no jokes about morning wood ok Robot Very Happy).

The books out there cover the ARM core, but beginners need to know how things relate to the kit they have in front of them. Dont assume that they will learn on say a freescale platform and then at a later date transfer to silicon labs because the chip is better or its more energy friendly, it wont happen. The way people learn is changing and my generation in particular is highly likely to stick with what they first learnt on. My dad is an embedded engineer of 30+ years experience, but how he learnt and how he thinks is way different to how people my age are doing it, he is teaching 8-11 year olds micro's and science using silicon labs products, they are learning because he is using material he designed himself, he uses C code but starts with a kind of library that they use first.

Many will point out were I am wrong and I am sure what they will say is totally true at the moment, but I will be right in 10-15 years. So in summary what I am saying is just add a couple of the old programs back into simplicity studio, look at the uni stuff you have and add some more with a little bit more detail, make it easier for people trying to teach themselves, the configurator is great once you know how to do the basics without it.

Trust me on this there is a well known competitor thats changed its policy on students recently, nothing much will change for them for a good few years, but down the line they are seriously going to hit problems.

I will post links to my reviews when I have them finished

LG

Posts: 546
Registered: ‎10-12-2004

Re: Blinky example for C8051F996-TB Problems

Hi all,

 

I've added an internal ticket to add the Basic Blinky without Configurator back in for the devices that are supported by Configurator.  I've also added a ticket with the Configurator UI suggestions in this thread.

 

Please let us know if you guys have any other feedback!  We're always looking to improve these tools and our examples.

 

~Tabi

Tabitha Parker
Senior Manager of MCU and Micrium Applications
Silicon Laboratories
Posts: 76
Registered: ‎12-19-2014

Re: Blinky example for C8051F996-TB Problems

I'm using a TB C8051F380 and Id started with this kind of programming only a few weeks ago. For me it would have been really helpful when in the readme of HIDtoUARTExample would be mentioned that i have to place a shorting block between tx and rx. I'm a complete newbe and this would have saved me more than an hour of searching the mistake Robot wink

 

Nice regards

 

Posts: 8,176
Registered: ‎08-13-2003

Re: Blinky example for C8051F996-TB Problems

. I'm a complete newbe and this would have saved me more than an hour of searching the mistake

 

OK, it would have been nice, but kust think of how much you learned while searching for the solution.  A large part of my knowledge has been acquired by looking for solutions to something else

erik
Posts: 267
Registered: ‎03-14-2014

Re: Blinky example for C8051F996-TB Problems

Great too see Erik!

I kind of agree and dissagree with you, when right at the start the searching for small things can make you give up, personally I think you need a few projects that work straightaway to give you confidence, then you learn by searching. I also agree that simple information like using jumpers should be easilly visiable, the more simple you make things for beginners the bigger and faster you grow your user base.

On the other hand beginners should not expect to build a rocket ship as a first project, its boreing but flashing a LED actually teaches you alot, thats why its normally the first thing sugestead, if you just want a one off project up and working then fair enough, but if you want to learn then there is a learning curve and some pain involved.

The one thing I like most about Silicon labs is they listen and respond to customers, this matters more than the little niggles, a company that says ok you dont like X or Y we will change it is a rare thing these days. For reasons I wont go into some of the competition have forgotten this and soon they will regret.

 

Thanks for the replies its been useful, my reviews are nearly ready Robot Very Happy, I have had a few mini exams to do so I am behind a week or two

 

LG