Project

General

Profile

A little bit of documentation, which might be helpful ?

Added by plutonomore about 1 year ago

Hi,

I bought a JNZ v4 some time back from Digital Smarties. I had always intended to design and build a
modified clone of this myself and not use JCW's JNZ v4 at all ... didn't mind parting with the 18 odd
Euros for the JNZ v4 equipped with a RFM69 CW radio module, considering the amount of time and
effort that JCW must have put into getting his board and firmware, "out-there" for the rest of us to play
with.

Have built a couple of clones of late. Some use the RFM69 HW module and others use the JeeLab
standard RFM69 CW module. The form factor also is quite different , much like an Arduino footprint.
Anyway, have been having a bit of fun playing with this thing and thought I might share a few basics
which might be of use to others ... please note this is specific to the JNZ v4/clones.

Let's start with the GPIOs. JNZ has three usable GPIO ports, A, B and C. For each of the ports there are 11
registers, ($00 to $28) that can be configured to control the GPIOs. Please see STM32L052K Reference
Manual (RM0376) pages 248 & 249/989 for heaps of detail. Port A is memory mapped at $50000000
to $500003FF. Port B $50000400 to $500007FF and port C $50000800 to $50000BFF. I cobbled together
a little string of 5 LEDs and 1K pullup resistors to hang-off port A bits PA3 to PA7, to play with setting and
resetting the port bits. Used OMODE-PP PA3 IO-MODE! OMODE-PP PA4 IO-MODE! OMODE-PP PA5
IO-MODE! OMODE-PP PA6 IO-MODE! OMODE-PP PA7 IO-MODE! to set up port A bits PA3 to PA7 as
push-pull output. Then wrote $57 into the GPIOA_ODR register which lives at $50000014. This lights up
the LEDs attached to bits 3,5 and 7 of port A. $57 $50000014 ! performs this magic. You can use $5000
0000 $20 DUMP to produce a hex dump and check that 50000014 does indeed contain $57. You
could also type $50000014 @ . and see $50000014 @ . 57 ok. reported.

SRAM is memory mapped at $20000000 to $20001FFF (8K). Only about a half of this is available to
play with, so try reading and writing SRAM at something like $20001000. Mecrisp reports that 4960 bytes
of RAM available. Type $8E $20001000 ! ENTER and use the DUMP command again to see that $20001000
does indeed contain 8E.

FLASH is memory mapped at $00000000 to $0000FFFF (64K). Once again not all is available for use.
Mecrisp reports 21248 bytes of FLASH free. E2PROM lives at $08080000 to $080807FF (2K).

I realise this is all pretty basic stuff but if I could have found stuff like this earlier, it sure would have
saved a lot of pain ... therefore am hoping this is of use to others interested in playing with this toy.

                                                                              cheers,

                                                                                        Matt.

PS. my apologies to any masochists out there!


Replies (2)

RE: A little bit of documentation, which might be helpful ? - Added by jcw about 1 year ago

Thanks for this post, Matt. I'm trying to understand how we could collect this sort of knowledge to better help anyone interested get started with this kind of hardware and Mecrisp. Is it a matter of creating a nice set of simple examples? Would it help to set up a section of examples at the new-born docs.jeelabs.org site? I don't want to duplicate the massive amount of information of the STM32 µC's in their reference manual, but agree that it's not a great way to get started if you have to find your way around in 100's of PDF pages before getting anything done. So yeah, perhaps grab a copy of the PDF to make sure all page refs stay valid, and then write up a set of examples with explanations. Or perhaps I should start by listing the intro material already posted, but buried deeply in the ever-continuing jeelabs weblog?

RE: A little bit of documentation, which might be helpful ? - Added by plutonomore about 1 year ago

Hi,

This is just a quick follow-up on the previous post concerning the STM32L052K8T6
and specific to JeeNode Zero v4 / clone GPIO usage ... might be helpful?

Suppose we wanted to program port A bits PA0 to PA07 as push-pull output and
set these bits low, we could achieve this as follows:

OMODE-PP PA0 IO-MODE!
OMODE-PP PA1 IO-MODE!
OMODE-PP PA2 IO-MODE!
OMODE-PP PA3 IO-MODE!
OMODE-PP PA4 IO-MODE!
OMODE-PP PA5 IO-MODE!
OMODE-PP PA6 IO-MODE!
OMODE-PP PA7 IO-MODE!
PA0 IOC!
PA1 IOC!
PA2 IOC!
PA3 IOC!
PA4 IOC!
PA5 IOC!
PA6 IOC!
PA7 IOC!

Any LEDs attached to PA0 to PA07 will be ON… don’t forget the LED current limiting resisitor, 1k ohm is good.

We could also achieve the same thing as follows:

$EBE95555 $50000000 !

Why is it so ? … my apologies to Julius Sumner Miller!

The GPIOA_MODER register is memory mapped to $50000000. This register sets up the GPIO mode, using two bits for each of the port A IO pins. 00: Input mode 01: General purpose output mode 10: Alternate function mode 11: Analogue (reset state)

Typing binary $50000000 @ u. followed by a carriage return produces:
binary $50000000 @ u. 11101011111010010101010101010101 ok.

The 01 setting for A0 to A07 (first sixteen binary digits) tell us that these IO pins have been set up as General purpose output.

At this stage I should confess to cheating a bit with the example I chose. Normally things would not be as easy as this ... why you might ask?
The GPIOA_OTYPER register is memory mapped to $50000004. This register sets
up the GPIO output type, using one bit for each of the port A IO pins. 0: Output push-pull (reset state) 1: Output open-drain

Typing binary $50000004 @ . followed by a carriage return produces:
binary $50000004 @ . 0 ok.

The 0 setting for A0 to A7 (first eight binary digits) tell us that these IO pins have
been set up as Output push-pull (reset state) by default and in this case we do not have to write anything to the GPIOA_OTYPER register.

The GPIOA_ODR register is memory mapped to $50000014. This register sets up the GPIO port output data, using one bit for each of the port A IO pins. 0: Reset bit 1: Set bit

Typing binary $50000014 @ . followed by a carriage return produces:
binary $50000014 @ . 0 ok.

The 0 setting for A0 to A7 (first eight binary digits) tell us that these IO pins have also been set up as 0 (reset state) by default and once again in this case we do not have to write anything to the GPIOA_ODR register. The downside of writing data to the GPIOA_ODR register is that the state of the other pins in the register are not preserved. We can get around this though … we can use the GPIOA_BSRR and GPIOA_BRR registers!

The GPIOA_BSRR register is memory mapped to $50000018. Setting a reset bit in this register, if it is initially reset, will set the same bit in the GPIOA_ODR register and preserve the state of the other pins.

OK, let’s reset Mecrisp or hit the clone reset button and type the following:

$EBE95555 $50000000 !
$00FF $50000018 !

The above line of code writes 0000000011111111 to the GPIOA_BSRR register.

Typing binary $50000014 @ . followed by a carriage return produces:
binary $50000014 @ . 11111111 ok.

Any LEDs attached to PA0 to PA7 will be OFF

The GPIOA_BSR register is memory mapped to $50000028. Setting a set bit in this register, if it is initially set, will reset the same bit in the GPIO_ODR register and preserve the state of the other pins. Type the following line:

$00FF $50000028 !

The above line of code writes 0000000011111111 to the GPIO_BRR register.

Typing binary $50000014 @ . followed by a carriage return produces:
binary $50000014 @ . 0 ok.

Any LEDs attached to PA0 to PA7 will be ON.

So, to turn ON only the LEDs attached to PA0, PA2, PA4 and PA6 using the GPIOA_BSRR register, first reset Mecrisp and then type he following:

$EBE95555 $50000000 !
$00AA $50000018 !

The above line of code writes 0000000010101010 to the GPIOA_BSRR register.

Typing binary $50000014 @ . followed by a carriage return produces:
binary $50000014 @ . 10101010 ok.

There you go, LEDs attached to A0, A2, A4 and A6 are lit, while LEDs attached to A1, A3, A5 and A7 are not!

This has been a bit of an introduction to using five of the eleven STM32L0528T6 GPIO registers. If you are interested in playing with some more yourself, you might find the STM Reference Manual (RM0376), pages 233-248/989 worth a read.

.

    (1-2/2)