I have the latest code from the forum for cw10.2 & an4368, that compiles without errors for the k60 tower board.
I was unsure of the correct processor type, so I created a debug configuration for both the k60N512Z, and k60N512MLV10; we get the same failure on both. (I looked but I can't see the difference between these two processors). I rebuilt all the mqx libraries, bsp, psp, mfs, usb for the mqx k60 tower project
The code runs to the point where the stack and pc counter are loaded. The stack and pc counter always loads as 0xffffffff. The switch value on PTA19 is correct at 0x80000.
New_sp = IMAGE_ADDR[0];
New_pc = IMAGE_ADDR[1];
When the sp, and pc are loaded from here they are always 0xffffffff. So I thought that there must be something wrong with the build, or something is not set up correctly. I followed the app note but without success. I also tried where someone on the forum turned off the USB peripheral clock, but no luck.
The PE terminal program is running on Win 7, sp1 and is version 2.05, the latest that PE has. The port will open but nothing is printed on the screen. All the jumpers are on the board as per the appnote.
The .mem file is what was in the base project.
KEEP_SECTION { .vectortable }
KEEP_SECTION { .cfmconfig }
MEMORY {
interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001E0
code (RX) : ORIGIN = 0x00000410, LENGTH = 0x0007FBF0
data14000000 (RW) : ORIGIN = 0x14000000, LENGTH = 0x00001000
data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00020000
cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000400
}
I can see where everyone on the forum seems to get this to work out of the box, so I am not sure of the error I am making. Any help would be much appreciated. Thanks.
Robert
SECTIONS {
# Heap and Stack sizes definition
__heap_size = 0x6000;
___stack_size = 0x2000;
Solved! Go to Solution.
Hi Robert,
My answer on other post helps to setup the printf() to be used on the TWR-SER card.
Reference post:
https://community.freescale.com/thread/301339
Regards,
David
I assume only the bootloader application is in the flash, and you would like to enter bootloader mode to bootload your MQX based application ? If so, it seems like the bootloader mode is not active. Can you try to keep the SW1 button pressed and reset the board ? I think the bootloader application should enter the code where it checks for USB memory stick attach, not the "Jump to user vector entry" code, as there is none at the moment.
yes, that is correct. I did try as you suggested, reset, hold down the sw1 switch. The program executes the function SwitchMode(), which checks the pc and sp. This is where it is failing; it loads 0xF...F into these registers.
I hit the main rtn ok, in SwitchMode, the pc and sp get loaded from here
New_sp = IMAGE_ADDR[0];
New_pc = IMAGE_ADDR[1];
These are 0xF...F.
This is where it goes wrong. I can see it picking up the switch ok.
temp =(uint_32) ((1<<19) & GPIOA_PDIR); /* DES READ SW1 of TWK60 */
This comes back as
temp | 0x80000 | 0x1fff96e8 |
Thanks for replying
Robert
void main()
{
/* Body */
USB_STATUS status = USB_OK;
_usb_host_handle host_handle;
uint_32 i;
/* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */
_bsp_platform_init();
GPIO_Init();
/* Protect bootloader area (sector 0 to sector 3)*/
#ifdef __MCF52259_H__
#ifdef __DEBUG__
MCF_CFM_CFMPROT = 0x0F;
#else
MCF_CFM_CFMPROT = 0x07;
#endif
#elif defined(MCU_MK60N512VMD100)
FTFL_FPROT3 = 0xF0;
#endif /* End __MCF52259_H__ */
#ifdef __DEBUG__
sci1_init();
#endif
for(i=0;i<=2000;i++);
Switch_mode(); /* check for bootloader mode */
TimerInit();
POLL_init(); /* Init polling global variable */
I think it is correct that it reads all 0xFFs as the flash is blank at these addresses.
In case the bootloader mode should be active, the Switch_mode() function returns back to the caller:
if(temp)
{
if((New_sp != 0xffffffff)&&(New_pc != 0xffffffff))
{
/* jump to user application */
}
}
By the way, by looking into TWRK60N512 schematic, if SW1 button is pressed, it reads back 0, not 1, as the button connects GND to the MCU input. So you may also want to connect a scope on the signal and see if it really goes low when the button is pressed.
I cannot get the terminal program working so I have break pointed through the code.
I see what you mean about the sp and pc not having a valid flash address and as you pointed out it is because we have to flash the code first; that was not happening. I traced the code through and the next thing that should happen is to attach the USB device. I saw it do it once and go into the bootinit() function. But I had the image name wrong, however I could see the file system working. That only lasted once, I corrected the name and it has failed every time since to attach the USB; so it never gets to bootinit(). The device is registered successfully according to the return status. Then it goes into the polling routine waiting for the usb status to be attached but that never happens. The interrupts were turned on after the usb device handler registration, but I still do not detect an event. So the system just sits in a loop waiting for the usb to be attached. I have removed and installed the usb flash drive, but nothing happens.
I also tried powering off and on, reload and run to the breakpoints. I have a breakpoint set at the callback
void usb_host_mass_device_event
It never gets here.
Thank you.
Robert
Hi Robert,
My answer on other post helps to setup the printf() to be used on the TWR-SER card.
Reference post:
https://community.freescale.com/thread/301339
Regards,
David