Locked out Evalbot Stellaris lm3s9b92

Yesterday I locked the MCU in my Evalbot. It was a result of flashing a wrong configuration of clock sources and dividers. I must have set the crystal frequency wrong and JTAG was no longer responding. At first it seemed to be dead totally, but then I found a software from TI named LM Flash Programmer. It has an option to unlock the MCU by erasing flash of the device, after we put it into a state before the flash is executed by asserting a reset on power up.

So, off we go:

1. The markings on my chip are:

LM3S9B92, IQC80B1XA

B1 here denotes the revision of the chip, what will be important later on.

2. Turn on LM Flash Programmer (it can be found here http://www.ti.com/tool/lmflashprogrammer). I used build 1381- the current one on the day of writing this post. When you choose the connection settings check what board do you have and even more important what crystal is on the board. When I chose “Lm3s9b92 Evaluation board” it specified 16Mhz crystal (the one on the board is 6MHz only), so I think that is a different board and there is no choice for evalbot. So the manual settings with ICDI, 1MHz Jtag, 6MHz crystal are fine.

3) The Port Unlock function that is of interest to us is located on Other Utilities tab. My MCU turned out to be (after a google search) to be a Tempest class, so this was the proper option to choose.

After clicking Unlock and reading the warning about erasing MAC address from flash (I think LM3S9B92 doesn’t come with any MAC programmed in, but either way there was no other choice) as well as all the other data located there, this window showed:

4) What that means is that according to the MCU data sheet “section 4.3.4.3 Recovering a “Locked” Microcontroller” we need to assert ~RST signal and then turn on the power (the specific pin could be different in other models). In this case it means to tie it to the ground (it is a negated pin). From the Evalbot schematics (www.ti.com/lit/ug/spmu167/spmu167.pdf) we can see that the ~RST pin has no information about the test point assigned to is (schematics are not complete, but still useful). The nice fact is that this pin is a part of JTAG, so most probably it should be also on the additional connection for this interface. After finding the pin on the pin layout in datasheet:

5) We can locate the connection on the JTAG pins with the multimeter:

The connection to the ~RST pin is located on the JTAG on the top row, most left (looking in the way that you can read the JTAG label on the PCB. My board is a bit different then on the schematics and placement figure from TI, so this little investigation was necessary.

6) Remove batteries, unplug usb ( if you don’t have a diode connecting ICDI to power, remove both of the cables- one connected to USB DEVICE port, and other ICDI port ), Tie RST pin to the ground and then plug in the power (both usbs) and turn the EVALBOT with the ON button. This should result in putting the MCU in the state that is not dependent on the flash content (the proper pin assignments and proper clocking). Now you can click ok on the dialog in LM Flash programmer about asserting reset. It will tell you to remove the ground from reset- do it.

7) Now if you are lucky it may be enough to click ok and the MCU should be unlocked (what will be confirmed with a proper dialog window). If you have a defective revision (keep in mind that I have a B1) you may have to do some more witchcraft. This is the information I found on TI forum (written by “Stellaris David” on of TI employees):

Hello,

Are you able to unlock the part using LM Flash Programmer?  Please give it a try.  After erasing the part, try and load the default example once more.

Be aware, with the LM3S9B92 Rev B1 you need to follow a slightly modified procedure to unlock the part.  This is located in section 1.2 of the Rev B1 errata document:

1.2 The Recover Locked Device sequence does not work as expected

Description:

If software configures any of the JTAG/SWD pins as GPIO or loses the ability to communicate with the debugger, there is a debug sequence that can be used to recover the microcontroller, called the Recover Locked Device sequence. After reconfiguring the JTAG/SWD pins, using the Recover Locked Device sequence does not recover the device.

Workaround:

To get the device unlocked, follow these steps:

  1. Power cycle the board and run the debug port unlock procedure in LM Flash Programmer. DO NOT power cycle when LM Flash Programmer tells you to.
  2. Go to the Flash Utilities tab in LM Flash Programmer and do a mass erase operation (check ”Entire Flash” and then click the Erase button). This erase appears to have failed, but that is ok.
  3. Power cycle the board.
  4. Go to the Flash Utilities tab in LM Flash Programmer and do another mass erase operation (check “Entire Flash” and then click the Erase button).

-David

If you are reading this David, thank you- it was a great information, which I didn’t catch when looking through Errata. In my case the initial unlock and erase seemed to work (there was no information about the error), but I still did double erase to be sure. Still the information is great in case you have B1 revision (mine is from the big promocode that was published on Hackaday and then turned out to be limited to Boston conference attendees).

Hope this info will help at least one person that locked their LuminaryMicro/TI microcontroller. Evalbot is a great way to learn some of the operation of LM’s and how to operate ethernet with mcu.

Posted in Uncategorized

Bluetooth ECG

My first master thesis was a ECG system that was supposed to communicate with the PC or PPC by bluetooth. It turned out rather well (except that the enclosure was a bit rough). The hardware was a self designed pcb with st-micro arm7 processor. It runs FreeRtos and some nice features- adc does most of signal acquisition with DMA up to the point of putting it all in the queue. All the design files and master thesis pdf is given below.

The pdf file with the while ECG masterthesis. (Good place to start)

The second thing is Altium designer files with the schematic and pcb: Altium pcb and schematics.

A viewer to see the data in wave form representation: viewer PPC i PC.

Workspace with source code for eclipse with ARM Code sorcery compiler is here: sourcecode.zip.

You may need sources for FreeRTOSV5.2.0, code sorcery arm lite compiler suite to compile the sources, and some way to put it in the processor if you would like to play with the code. I have it all somewhere if anybody is interested, but it should be easily available on the net. I used usb-uart 3.3v converter to upload the code(no way to debug by wire in my case).

 

The signal flow based on timer triggered ADC and DMA transfers

 

PCB was designed to be compact and keep the most noise sensitive signals far from DC/DC converter.

What is also interesting is the organization of different tasks- some were responsible for ADC and some for menu on lcd and button debouncing.

 

Posted in Electrical engineering, Technology Tagged , , , ,

Evalbot’s sound chip error in documentation

Past three days I’m working on turning on the sound output on my Evalbot based on stellaris chip. It has a nice sound chip TLV320aic3107 that is controlled through I2C and fed with data through I2S. I must say that it takes a great deal of fiddling with registers of this little thingy to get it to output anything on the speaker through D class amp. The code I used to set all the values is below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
void vInitAudioOut(void)
{
    arrayLength = sizeof(dataFile)/sizeof(dataFile[0]);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_7);
    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_7,GPIO_PIN_7);
    SysCtlDelay(200);
    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_7,0);
    SysCtlDelay(200);
    GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_7,GPIO_PIN_7);
    SysCtlDelay(200);
 
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinConfigure(GPIO_PB6_I2S0TXSCK);
    GPIOPinConfigure(GPIO_PE4_I2S0TXWS);
    GPIOPinConfigure(GPIO_PE5_I2S0TXSD);
    GPIOPinConfigure(GPIO_PF1_I2S0TXMCLK);
    GPIOPinConfigure(GPIO_PD4_I2S0RXSD);
    GPIOPinTypeI2S(GPIO_PORTB_BASE, GPIO_PIN_6);
    GPIOPinTypeI2S(GPIO_PORTD_BASE, GPIO_PIN_4);
    GPIOPinTypeI2S(GPIO_PORTE_BASE, GPIO_PIN_4|GPIO_PIN_5);
    GPIOPinTypeI2S(GPIO_PORTF_BASE, GPIO_PIN_1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2S0);
    //SysCtlPeripheralReset(SYSCTL_PERIPH_I2S0);
 
    UARTprintf("I2S: MCLK set to %d\n",SysCtlI2SMClkSet(0,12288000));
    I2SMasterClockSelect(I2S0_BASE, I2S_TX_MCLK_INT|I2S_RX_MCLK_INT);
    I2STxConfigSet(I2S0_BASE,I2S_CONFIG_FORMAT_I2S|I2S_CONFIG_MODE_COMPACT_16|I2S_CONFIG_SAMPLE_SIZE_16|I2S_CONFIG_WIRE_SIZE_32|I2S_CONFIG_CLK_MASTER|I2S_CONFIG_EMPTY_REPEAT);
    I2STxEnable(I2S0_BASE);
 
    //I2S Interrupt settings
    I2STxFIFOLimitSet(I2S0_BASE, 8);
    I2SIntEnable(I2S0_BASE,I2S_INT_TXREQ);
    I2SIntRegister(I2S0_BASE, I2S0_Interrupt_Handler);
 
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    GPIOPinTypeI2C(GPIO_PORTB_BASE,GPIO_PIN_2|GPIO_PIN_3);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
    SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0);
    I2CMasterInitExpClk(I2C0_MASTER_BASE,SysCtlClockGet(),false);
 
    //Configure Bumper L switch as the input pin E1
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1);
    //Configure LED2 as output
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_5);
 
    //Initialize IC for use with D-class amp, as in datasheet (non documented registers)
    TLVSetRegister(0x00, 0x0D);
    TLVSetRegister(0x0D, 0x0D);
    TLVSetRegister(0x08, 0x5C);
    TLVSetRegister(0x08, 0x5D);
    TLVSetRegister(0x08, 0x5C);
    TLVSetRegister(0x00, 0x00);
 
    //Initialize IC for D-class amp
    TLVSetRegister(101, 0b00000001); //CODEC CLOCKIN from CLKDIV_OUT
    TLVSetRegister(102, 0b00000010); //CLKDIV_CLKIN used MCLK, N=2
    //TLVSetRegister(94, 0b11011110); //power up dacs
    //TLVSetRegister(98, 0b10111000); //GPIO clock out
 
    TLVSetRegister(73, 0b11111000); //turn on d-class amp
    TLVSetRegister(70b00001010); //left channel to play left samples
    TLVSetRegister(37, 0b11000000); //turn on left dac and right dac
    TLVSetRegister(41, 0b01010000); //left dac to left line output, right dac to right line output
    TLVSetRegister(43, 0b01110000); //left dac not muted  gain on minus something
    TLVSetRegister(44, 0b00110000); //right dac not muted  gain 0 //on minus something
 
    TLVSetRegister(90b00110000); //audio word length 32b
 
    TLVSetRegister(82, 0b10000000); //route DAC_L1 to LEFT_LOP
    TLVSetRegister(85, 0b10000000); //route DAC_R1 to LEFT_LOP
    TLVSetRegister(86, 0b00001000); //LEFT_LOP unmute 0db gain
    TLVSetRegister(93, 0b00001000); //RIGHT_LOP unmute 0db gain
 
    UARTprintf("TLVreg 94: %x\n", TLVGetRegister(94));
    UARTprintf("TLVreg 86: %x\n", TLVGetRegister(86));
    UARTprintf("TLVreg 93: %x\n", TLVGetRegister(93));
    UARTprintf("TLVreg 82: %x\n", TLVGetRegister(82));
    UARTprintf("TLVreg 43: %x\n", TLVGetRegister(43));
    UARTprintf("TLVreg 44: %x\n", TLVGetRegister(44));
    UARTprintf("TLVreg 101: %x\n", TLVGetRegister(101));
    UARTprintf("TLVreg 73: %x\n", TLVGetRegister(73));
 
    UARTprintf("Size of data sample: %x\n", sizeof(unsigned int));
}

The problem is here:

79
80
TLVSetRegister(86, 0b00001001); //LEFT_LOP unmute 0db gain
TLVSetRegister(93, 0b00001001); //RIGHT_LOP unmute 0db gain

According to datasheet the registers 86 and 93 ( Output Level Control Register) have D0 bit only readable and not writable.

Stellaris Register 86

If D0 = 0 then LOP is not fully powered up, if D0=1 then LOP is fully powered up. So if you won’t set a bit that is supposed only to be read then you get only a very faint quiet sound (the oscilloscope doesn’t show any wave even on 20mV range, but you can still barely hear it on the speaker). I would assume that it is just some crosstalk from the input of LOP to the output.

After correcting the bit to 1 the sound is great and loud. Success.

The sourcecode I use is here Ethernet_stellaris it is developed under CoIDE with CoOS realtime operating system.

 

Edit: I asked about the subject on the TI’s forum and I hope it’s ok if I put it here:

Posted by Converter Apps:

Yes, Sorry for the confusion. Register 86 and 93 on Page 0 should show bit D0 as R/W. This is the only way to turn on the Line Outputs.

Also for the Class D, be sure to include the initialization code shown on page 46 of the data sheet.

Also I asked about the funny initialization sequence that is in the datasheet (the one mentioned by Converter Apps) – what is it for and what does it do:

Posted by Converter Apps:

This code goes to page 14 to disable some features that were not released on the AIC3107. There are no user options and the exact sequence is needed to insure that the Class D operates as intended. Since there are no user options we don’t specify the details of these registers.

So at least I know I’m not making this issue up.

Posted in Uncategorized

VHDL Multiplication module IP generator

User interface

For my second master thesis I wrote a generator of VHDL multiplier modules. Software was written in C# and allows to implement several algorithms of multiplication of inputs upto 128bits (for some cases more) and with different sign representation of input/output. I hope it can be useful for some of you guys.

My master thesis (pdf): VHDL Multiplication modules IP generator

Software project files (zip): VHDL Multiplication module IP generator software Visual Studio Project

Software installer files (zip): VHDLMultiplication module IP generator Installer

Continue reading

Posted in Electrical engineering Tagged , , ,