Author Topic: Need help getting started with MCF51JU32VFM microcontroller.  (Read 1331 times)

0 Members and 1 Guest are viewing this topic.

Offline Dukov AhzrukhalTopic starter

  • Regular Contributor
  • *
  • Posts: 51
  • Country: us
Need help getting started with MCF51JU32VFM microcontroller.
« on: October 09, 2019, 02:09:23 am »
Hello everyone, I recently got a tiny MCF51JU32VFM microcontroller that I want to use for my future projects. Unfortunately I havent been able to figure out how to do even the most basic things with it. I have only used PIC and AVR microcontrollers before, and I always program them in assembly. This is my first time trying to use C for a microcontroller and apparently I picked the wrong chip to start with. Could anyone help me figure out how to configure and control the GPIO pins and have a delay function? right now I simply want to write a blinky program. It may sound silly but just having that as an example will get me a long way. I am already familiar with C and C++, just not for microcontrollers.

Any help would be highly appreciated.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #1 on: October 09, 2019, 05:47:11 am »
Looks like you need an IDE for the Coldfire V1 CPU.
Then you need a programmer compatible with the IDE and the Freescale part.

Looks like you can work with CodeWarrior and an UMultilink. ($395.00 + $200)

Unfortunately, this isn't as accessible as ST's ecosystem with free tools and cheap development boards with debugger includes.
 

Offline mfro

  • Regular Contributor
  • *
  • Posts: 210
  • Country: de
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #2 on: October 09, 2019, 06:10:02 am »
The MCF51JU32VFM is a ColdFire series chip.

Although I do not have experience with this particular chip (only with ColdFire V4), I think it should be fully supported by GNU tools (binutils + gcc + gdb). Its probably not easy to find a readily compiled toolchain for this chip, but building binutils and gcc as cross compiler yourself is easy and straightforward.

If you are of decent age, it will help a lot if you have experience with Atari's and Amiga's you can dig out - these chips are very similar to popular m68k chips.
« Last Edit: October 09, 2019, 06:12:48 am by mfro »
Beethoven wrote his first symphony in C.
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2328
  • Country: 00
 
The following users thanked this post: Dukov Ahzrukhal

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8277
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #4 on: October 09, 2019, 11:43:12 am »
You can program any MCU in Asm. Just read through the documentation and configure the peripherals you need:

http://cache.freescale.com/files/32bit/doc/ref_manual/MCF51JU128RM.pdf
https://www.nxp.com/docs/en/data-sheet/MCF51JU128.pdf
 

Offline Dukov AhzrukhalTopic starter

  • Regular Contributor
  • *
  • Posts: 51
  • Country: us
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #5 on: October 09, 2019, 04:15:27 pm »
I have downloaded CodeWarrior and created a project  already. This microcontroller has a thing called EzPort, which as far as I can tell is just an SPI interface. Since I dont want to buy an expensive programmer I was planing on using an arduino to program this MCU. What I cant figure out is how to have delay loops in C. Also for the GPIO I'm just declaring pointers and assigning them with the correct register addresses, but I'm sure there is a better way to do this.
I wouldn't mind using assembly, but this is a fairly powerful microcontroller and the tasks I need to do are very simple so I dont need to worry about optimizing things. I think it makes sense to use C.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #6 on: October 09, 2019, 05:16:22 pm »
Using assembly and making your own programmer? So much effort... Is there anyhing specific you require that other more common parts don't suffice?
 

Offline Dukov AhzrukhalTopic starter

  • Regular Contributor
  • *
  • Posts: 51
  • Country: us
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #7 on: October 09, 2019, 07:10:53 pm »
My current project is simple, I simply need to emulate a tape drive for  a TRS80. I could use any other microcontroller for that, the reason why I'm trying to use this one is simply because I already have it and I want the experience of using something other than PIC or AVR. I know using this part will make my life harder than it needs to be, but I'm just trying to learn so the harder the better.
 

Offline Dukov AhzrukhalTopic starter

  • Regular Contributor
  • *
  • Posts: 51
  • Country: us
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #8 on: October 09, 2019, 09:24:04 pm »
Ok, I think I figured out the IO part, but I still haven't been able to figure out the delays. Am I supposed to use the time for all delays?
I wrote some code with what I have s far, but before I start messing around with making my own programmer for the chip can someone please read my code and tell me if it has any chance of working? At least it compiles...
 

Online mariush

  • Super Contributor
  • ***
  • Posts: 5030
  • Country: ro
  • .
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #9 on: October 09, 2019, 09:52:26 pm »
I know it doesn't help, but if you're in the mood to learn something new, why not try something with an ARM core, or maybe something 8051 based ... for example see Silicon Labs Busy Bee and Gecko series (ARM Cortex M0, M4, 8051) ... STM32F0, F4,  the PsoC chips?

What's the point of using an obscure chip that you may not be able to source easily and you don't have a cheap IDE, is there anything really special about it to be worth investing time in it?
« Last Edit: October 09, 2019, 09:56:00 pm by mariush »
 

Online pgo

  • Regular Contributor
  • *
  • Posts: 69
  • Country: au
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #10 on: October 10, 2019, 12:00:37 am »
Hi,

Development for the JU32 can be done with "Codewarrior for MCUs".  A special edition can be obtained from NXP (Freescale originally)
https://www.nxp.com/design/software/development-software/codewarrior-development-tools/downloads:CW_DOWNLOADS

A cheap debugging/programming interface is USBDM
http://usbdm.sourceforge.net/USBDM_V4.12/html/index.html

Hardware for the latter is available cheaply on ebay.

bye


 
The following users thanked this post: Dukov Ahzrukhal

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8277
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #11 on: October 10, 2019, 02:46:36 am »
I wouldn't mind using assembly, but this is a fairly powerful microcontroller and the tasks I need to do are very simple so I dont need to worry about optimizing things. I think it makes sense to use C.
On the contrary, the benefits of a HLL like C only show up when you need to do more computationally intensive tasks; if you're just poking at a peripheral, then Asm will work just as well and may even be shorter.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #12 on: October 10, 2019, 05:35:12 am »
Ok, I think I figured out the IO part, but I still haven't been able to figure out the delays. Am I supposed to use the time for all delays?
They way arduino millis and delay is implemented is using a timer for a system tick. So I suggest using a timer.
On ARM people use the systick or an timer on the AHB (from the vendor).
Arduino uses Timer 0.

However, if you need microsecond resolution inline delays there are other ways. Such as self-tuning soft delay loops.
 
The following users thanked this post: Dukov Ahzrukhal

Offline mfro

  • Regular Contributor
  • *
  • Posts: 210
  • Country: de
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #13 on: October 10, 2019, 03:30:24 pm »
... can someone please read my code and tell me if it has any chance of working? At least it compiles...

Your delay loop might work, but that is not the best way to do it. Your chip has multiple timers. At least one of them can be configured as free running counter (see the reference manual Ch. 36.4.4.3 http://cache.freescale.com/files/32bit/doc/ref_manual/MCF51JU128RM.pdf). Program the timer to a certain frequency and then just save the current value and have your code observe the counter in a loop (busy wait). Once the difference of saved and observed value reaches the value you need as a wait time, do whatever you want to do after the delay.

You could also have the FlexTimer generate an interrupt after a certain time, but that might be too much considering you are just starting.
Beethoven wrote his first symphony in C.
 

Offline Dukov AhzrukhalTopic starter

  • Regular Contributor
  • *
  • Posts: 51
  • Country: us
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #14 on: October 11, 2019, 06:11:06 pm »
I ordered a programmer for the MCU, I'll test my code when it arrives. In the meantime I'd like to learn more about using C to program MCUs. Would it be easier to start with a PIC MCU? Since using the MCF51JU32VFM turned out to be harder than I anticipated I will not use it for my current project. I'll keep playing around with it but for now I'll switch to using a PIC16C74B. Since I'm familiar with all the relevant IO registers already I should have no trouble getting the IO to work in C, but I'll need some carefully timed delay loops. The first thing I'll do is measure the length of a pulse (to decode data from a TRS80 tape). What would be a good way to do this? I'm using MPLABX, I can write my code in assembly and post it here if that helps anyone figure out exactly what I'm trying to do.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8277
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #15 on: October 12, 2019, 01:58:08 am »
If you want cycle-exact timing, a compiler in any HLL won't ever give you that, because it's not very predictable the exact instructions it'll generate. HLLs are meant to be more abstract.
 

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8654
  • Country: gb
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #16 on: October 12, 2019, 02:10:03 am »
If you want cycle-exact timing, a compiler in any HLL won't ever give you that, because it's not very predictable the exact instructions it'll generate. HLLs are meant to be more abstract.
These days most processors don't have an exact cycle timing for most code, as things like cache and pipeline behaviour make the timing fluid. However, there was a time when some HLL compilers for simpler processors output the number of cycles for particular paths through the code. For example, I used to get cycle accurate timing information from the Intel PL/M86 compiler for the original 8086.
 
The following users thanked this post: Dukov Ahzrukhal

Online westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #17 on: October 12, 2019, 02:13:50 am »
Quote
Code: [Select]
void delay()
{
    volatile int i;
    i = 0;
    while (i < 65536)
    {
        ++i;
    }
}
Your delay code looks "ok", assuming that an "int" is 32bits (which I believe is true of 68k derivatives including Coldfire v1.)  If int is only 16bits, it will never reach 65536, and it will loop forever.


If you're actually running at the documented clock rate of 50MHz, and blinking an LED, the blink rate is likely to be so fast that you can't notice (100Hz+)  Try something like "50e6/10" (For a one-second blink, estimating 10 cycles for a typical "increment and loop.")
 
The following users thanked this post: Dukov Ahzrukhal

Offline Dukov AhzrukhalTopic starter

  • Regular Contributor
  • *
  • Posts: 51
  • Country: us
Re: Need help getting started with MCF51JU32VFM microcontroller.
« Reply #18 on: October 28, 2019, 12:17:14 am »
I got the cable to program the chip, but unfortunately I keep getting a message that says "Connection to the target has failed" I probed the reset and BKGD lines and they do change when I try to program the thing, so the cable seems to be working. Am I missing something or did I break the chip? I have pin 7 and pin 24 tied to +3.3V pins 8, 14, 25 tied to GND, EXTAL1 and EXTAL2 tied to a 20MHz oscillator, and pins 28 and 21 connected to the programming cable. Everything else is unconnected except for pin 16 which is connected to an LED through a 470 Ohm resistor. I get no signal out of XTAL1 and XTAL2.
Using this chip is getting very frustrating  |O
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf