<tabemann>
the problem I have is enabling interrupts
<tp>
I'd like to take this opportunity to say that this forum is the best for tech info and real world programming I have seen yet!
<tabemann>
because almost all the examples I see use this damn HAL API
<tp>
tabemann, it starts with the NVIC
<tabemann>
whereas I want to see code that directly talks to the hardware
<tabemann>
I know that
<tabemann>
which bit do so I SETENA?
<tabemann>
*which bit do I SETENA?
<tp>
tabemann, yeah, thats why I made my interrupts page, everywhere else it's "use HAL"
<tp>
to find the right bit for setena you have to look in the NVIC section of your technical pdf
<tabemann>
and I know how to enable an EXTI channel with SETENA
<tabemann>
but the thing is which EXTI channel?
<tp>
this area initally caused me a LOT of confusion, for a long time
<tabemann>
and which pins on which EXTI channel?
<tp>
not all interrupts use exti
<tabemann>
what about USART?
<tp>
lets work thru your particular need ?
<tabemann>
I thought that configurable GPIO interrupts were EXTI
<tp>
thats true
<tp>
but lets start at your usart ?
<tabemann>
sure
<tp>
you will have a few different configs for this
<tp>
what interrupt will you use for the usart ?
<tabemann>
I know how to configure it to capture RXE AND TXNE
<tabemann>
that's the easy part
<tabemann>
a matter of setting bits on USART2_CR1
<tabemann>
and I know USART2 is configured to use GPIOD pins 5 and 6
<tp>
via AFx
<tp>
ok, so far so good
<tabemann>
so given that, what interrupt do I need to set?
<tp>
now I cant locate "RXE" or "TXNE" for the L476 but if you have that under control we can move on
<tp>
tabemann, there is a large choice of interrupts for USART2 that I can see
<tabemann>
yes, there are quite a few
<tabemann>
what I'm concerned with is:
<tabemann>
1) which vector do I use
<tabemann>
and
<tp>
this page deals with usart interrupts
<tp>
1374/1880 RM0351 Rev 6
<tp>
and the next page
<tabemann>
2) how do I enable the interrupt on that vector
<tp>
first you must choose a interrupt
<tp>
so we can work thru a example
<tabemann>
setting up RXEIE and TXNEIE is simple; my issue is doing what the HAL does with HAL_EnableIRQ() or whatever that's called
<tabemann>
where I saw people just feeding things named something like "IRQ_USART1" into that function
<tp>
I have no "RXEIE" or "TXNEIE" (if you want me to check the actual bitfields)
<tabemann>
USART2_CR1_RXEIE
<tabemann>
USART2_CR1_TXNEIE
<tp>
the problem with using C bitfield names is that most online examples are not complete, ambiguous or plain wrong, it's a soul destroying experience
<tabemann>
anyways
<tp>
I only have a "USART2_CR1_TXEIE" for the L476
<tp>
and I have a "USART2_CR1_RXNEIE" for it
<tabemann>
wait I got those backwards
<tabemann>
anyways
<tabemann>
now that I've enabled USART2_CR1_TXEIE and USART2_CR1_RXNEIE, what do I need to do to enable some interrupt, any interrupt for it
<tabemann>
for instance, do they use an EXTI
<tabemann>
(I found some example code online about how to configure EXTIs)
<tabemann>
USART2_ISR_TXE is set when USART2 is ready to transmit
<tabemann>
USART2_ISR_RXNE is set when USART2 has data to receive
<tp>
USART2_CR1_RXNEIE enables "Receive data register not empty (data ready to be read) RXNE" and "Overrun error detected ORE"
<tabemann>
setting USART2_CR1_TXEIE enables an interrupt for when USART2_ISR_TXE becomes true
<tabemann>
setting USART2_CR1_RXNEIE enables an interrupt for when USART2_ISR_RXNE becomes true
<tp>
USART2_CR1_TXEIE enables Transmit data register empty flag TXE
<tp>
what do you wish to use as your example ?
<tabemann>
I want to put the MCU to sleep with WFI
<tp>
youve enabled three sources for interrupts which is 2 more than we want for a example
<tabemann>
I want it to wake up when the user presses a key or becomes ready to send more dat
<tp>
I know that, but youre a LONG way from being able to do that
<tp>
ok, wake up on a keypress ... good
<tp>
for that you'll need to use "Receive data register not empty (data ready to be read)" I suppose
<tp>
I have never done this myself, so Im assuming here
<tp>
but it's also easy to test
<tabemann>
the key thing here is this - now that I've set USART2_CR1_TXEIE and USART2_CR1_RXNEIE, how do I translate these into actual interrupts that I can handle?
<tabemann>
because everything I read is unclear on this
<tabemann>
either they talk about HAL
<tabemann>
or they talk about NVIC and EXTI
<tabemann>
but they don't talk about having a USARTx and wanting it to raise interrupt y
<tp>
thats why i suggested we work thru a single example, a better one would have been a GPIO button press interrupt as theyre less complex, but also different
<tp>
you appear to be looking for a one line answer to this, I don't have one
<tabemann>
not one line
<tp>
I know how to use interrupts with forth, I have code showing that online
<tabemann>
I assume it involves SETENA
<tabemann>
which I know how to use
<tp>
but of course, your need is different to what I have working so far
<tabemann>
I think it likely involves an EXTI
<tabemann>
but I don't know offhand
<tp>
it does, and as critical as SETENA is, thats just one part
<tabemann>
and if it involves an EXTI
jedb_ is now known as jedb
<tabemann>
can I choose any EXTI?
<tabemann>
when for the part where I specify pins for an EXTI
<tp>
any that your hardware allows
<tabemann>
do I use the same pins that are used to configure the USART originally?
<tabemann>
and how do I select GPIOD rather than some other GPIO?
<tabemann>
because in the example code I see I see how to select pins
<tp>
Zarutian_HTC, but the msp430 is pretty slow, 16Mhz clock ?
<Zarutian_HTC>
for wakeup just put wakeup before the rfi
<tp>
too easy!
<Zarutian_HTC>
16 MHz is plenty fast for many mcu applications
<tp>
yes, so right
<tp>
Ive become used to 75MHz minimum
<tp>
once, 1MHz was plenty for me
<Zarutian_HTC>
if I need much beefer processing I usually do it on diffrent chip
<Zarutian_HTC>
that is have slowish main mcu then a faster coprocessor with its own memory on the side
<tp>
well thats only because you actually know what youre doing! :)
<tp>
the MSP430 is certainly the master of easy low power
<Zarutian_HTC>
means that one can have it more specialized or fitting to the application
<tp>
I havent lived in that world myself
<tp>
I have my stock of MCUS and make them fit my application
<tp>
for me it's all about my embedded tooling
<tp>
the mcu type is last for me
<tp>
if i cant properly debug the chip, I dont care how much betetr it is
<tp>
I seem to be one of the few in this regard tho
<Zarutian_HTC>
well, the handy thing is that one can use something like msp430 for the always on part and a cortex-m or dsp or what have you for the calculation heavy stuff
<tp>
lucky I'm not designing hundreds of millions of cellphones hey ;-)
<tp>
for me always cortex-m is better as I never need low power, but love having 33 peripherals to choose from
<Zarutian_HTC>
sometimes it pays off to use the same part for both main and coprocessor
<tp>
even if it's a horrible chip compared to the MSP430
<Zarutian_HTC>
same part type that is
<tp>
Ive never needed a copro, the f0 does fixed point for me in plenty of time
<tp>
but youre at the high end, Im right at the bottom
<tp>
someone will come to me needing a controller for some machine, perhaps to detect a jam or so on
<Zarutian_HTC>
eh, I rather do sensor integration with a dedicated processor
<tp>
it's a massive problem for them, they just want it to go away
<tp>
and it's always a mechanical problem, so really slow
<tp>
Zarutian_HTC, I do that as well, but at the very low end
<tp>
hehe
<Zarutian_HTC>
sure, I have never understood why some designers are always so damn stingy with simple sensors like limit switches or rotary tick encoders
<tp>
stingy, how ?
<Zarutian_HTC>
the sooner the machine can detect that something is wrong the better
<tp>
I think a lot of designers are inexperienced or unmotivated
<Zarutian_HTC>
too damn few of them in the machine
<tp>
ahh, not enough sensors on complex and expensive machines ?
<tp>
i guess that sensors are also a source of problems
<tp>
often a stoppage is caused by a faulty sensor in my experience
<Zarutian_HTC>
yes and plenty of assumptions on that mechanical side always works
<tp>
but I agree, I also think everything needs more sensor`s
<tp>
I did get to work in sensor heaven once
<tp>
when I was doing sensor maintenance on submarines, the worlds biggest money pit
* Zarutian_HTC
has serviced and run complex mechatronic machines
<tp>
Zarutian_HTC, same, plus worled in R&D most of my life building prototypes for engineers
<tp>
Zarutian_HTC, I have a lathe and a milling machine plus a pretty good mechanical workshop, I can basically build a solution for most things
<tp>
Zarutian_HTC, at age 66 and building gear since I was a kid, I have now forgotten about a lot of the stuff Ive designed and built
<Zarutian_HTC>
and what is up with the software for some of the machines? sometimes I want to be able to single step or slow run the machine to see where the problem is
<tp>
Zarutian_HTC, about 30 years ago a man came to my door with a interesting electronic device and asked for a quote to repair it
<tp>
I asked it what it did, where it came from and he looked at me oddly ...
<Zarutian_HTC>
what did that device do?
<tp>
he said, "it came from you, you made it for me"
<tp>
I cant remember
<tp>
I always used a logic analyser in the past but that stopped being useful with the PIC
<Zarutian_HTC>
aah, this is why makers mark or uuid for documentation tie in is so handy
<tp>
the PIC was a turning point for me, I made some decent stuff and money from it but realised that my ability to diagnose it (C lang) was just not good enuf
<tp>
at ar`ound that time I moved to the other side of Australia and started a Wifi business and my embedded stopped for 15 years
<Zarutian_HTC>
put the final documentation in various public places and when you google the uuid then you might have an fighting chance to find it again
<tp>
i keep excellent doc now so thats no problem
<tp>
so in 2014 I started getting back into embedded design and began looking for a very good design system that could also do in depth analysis
<Zarutian_HTC>
one fun story i heard was from a reverse engineer that found it odd that it had an oversized flash chip for what the device did
<tp>
k
<Zarutian_HTC>
turned out that it used to have a smaller flash chip but that part got duscintinued
<Zarutian_HTC>
discontinued*
<tp>
i find that the size of my code to do product fault testing etc is usually about the same size of the program
<tp>
sounds reasonable
<Zarutian_HTC>
like always the first thing he did was to dump its conents
<tp>
which is often locked or encrypted
<Zarutian_HTC>
the first two to five percent of the chip was the actual code to use and run diagnostics on the device
<Zarutian_HTC>
well it wasnt locked or encrypted
<tp>
and the rest was a copy of the bible ?
<tp>
a gif of the designer ?
<tp>
a sound byte that said 'get out of my code!" ?
<Zarutian_HTC>
the rest of the chip? it contained a heavily compressed tar file with all the project and design files, user and service manuals included
<Zarutian_HTC>
note this was in a device with expected service lifespan if 30 to 50 years
<Zarutian_HTC>
s/if/of/
<tp>
wow, thats awesome
<tp>
i dont get much into my 64kB m0's :)
<tp>
I have great respect for whoever made that project
<tp>
the item I have forgotten about was probably analog I have made a LOT of gear with no MCU
<tp>
I used to specialise in PSU's
<tp>
but basically I made anything that was electronic
<Zarutian_HTC>
note that this was on a 4 mb flash chip and all the files were in some ascii ish based formats so it compressed well
<tp>
wow thats even cleverer!
<tp>
and ascii means it can be read
<tp>
proving the compressed tar file can still be read
<Zarutian_HTC>
or at least figgured out. the manuals were .eps files with diagrams but not bitmaps
<Zarutian_HTC>
well it had a very distinctive 'magic' at the start of it
<tp>
than again in 50 years will the data still be there in the flash chip ?
<tp>
it sounds like a awesome desinher was involved
<tp>
he has my respect!
<Zarutian_HTC>
I thing the designer of the thing had been bitten by bad and none existant documentation on a similarly long service life device
<tp>
sounds reasonable
<MrMobius>
tp, random question but did you ever run across the RCA 1802 in your time?
<Zarutian_HTC>
well, why shouldnt it? the chip was treated like rom in the circuit
<tp>
MrMobius, I owned one
<tp>
I bouth 2 of the chips iirc
<tp>
bought
<tp>
but I didnt get past reading the tech doc, I didnt like them
<Zarutian_HTC>
1802? wasnt that a quad op amp chip?
<tp>
I've no idea where they are now, probably thrown away years ago to make room for chips I did like
<tp>
no, CDP1802 was a cmos cpu
<Zarutian_HTC>
oh that. And I guess cisc based
<tp>
dunno, was too strange for me
<Zarutian_HTC>
probably as horrible as Razon chips
<tp>
I was already in love with the mc6800 by then
<Zarutian_HTC>
now that is an orthogonal arch if i ever saw one
<tp>
they cdp1802 was also avail in rad hardened, so was used for space projects
<MrMobius>
ya 1802 is strange and takes a lot of cycles to do anything
<MrMobius>
quirky thing though and kind of interesting
<tp>
it was one of the first cmos mcu's iirc
<MrMobius>
what kind of system did you have it in?
<Zarutian_HTC>
tp: I thought most rad hard mcus in use are RTX 2010 which is a dual stack machine
<tp>
MrMobius, i had it in a special 'plastic parts draw' system ;-)
<tp>
Zarutian_HTC, I'm sure they are, but the 1802 was also avail in rad hardened
<tp>
probably only $10,000 extra
<tp>
i dont even want to revisit the 1802, Im still wierded out from the 70's when I read the doc
<tp>
wish I still had the chips to send to someone who really wanted one to study
<MrMobius>
hehe. i have some of those systems :P
<tp>
the 'wierd' ones ?
<tp>
MrMobius, do you have a old Victorian museum under your house, full of old systems in perfect working order by any chance ?
<MrMobius>
i wouldnt have to work if I did
<tp>
once when I was a teenager I visited a old DECA radio positioning system, it was a huge building, made of varnished wood and with polished brass, valves and busbars, it left a impression
<tp>
MrMobius, sure you would, private collectors museums cost money!
<tp>
oh it was a operational DECA building
<tabemann>
back
<tabemann>
guess what
<tabemann>
there's a dedicated USART2 interrupt
<tabemann>
I feel so incredibly stupid now
<tp>
why, youre clearly NOT stupid
<tabemann>
I missed it because in matthias's vector file it's not listed
<tp>
it's a massive challenge for a software person to do hardware
<tp>
(I wish that software people would also bear in mind that the reverse is also true)
<tp>
well, matthias hates ARM, I dunno why he ever wrote Mecrisp-Stellaris
<Zarutian_HTC>
do what I do, read the full datasheet through once
<tp>
but Im glad he did
<tp>
Zarutian_HTC, excellent tip
<tp>
i dont need it tho, because I love datasheets and reread them for enjoyment
<tp>
but then Im a tech
<tp>
Im not a tech because it was the only job I could get, at age 9 I knew I wanted to do electronics for the rest of my life
<tp>
it's a obsession for me
<Zarutian_HTC>
not fully comprehend or anything just page through it like you are reading the documentation of an software library yoy havent used for
<tp>
exactly, but after that tabemann will recognise the words later on
<tp>
and have some recollection of where he read it before
<tabemann>
back
<Zarutian_HTC>
similar for me. I would still geek out on this regardless of how well paid it is
<Zarutian_HTC>
if I wanted to be rich then I would be doing quatative analysus on second order finanical dervitives
<tp>
or a lawyer or politician if you have no scruples ?
<Zarutian_HTC>
which I find boring as hell
<tp>
and cry yourself all the way to the bank every day ?
<tp>
but electronics has a magic when done very well, like a perfect program, who can resist that ?
<Zarutian_HTC>
well, I once caught out a lawyer trying to pull a stunt in a contract he wrote. I had been asked to read it over to find any obvious logic flaws
<tabemann>
I always love building stuff and the moment that something just works
<tabemann>
I find it frustrating when I can't fix bugs, but just love it when I do fix them
<tp>
tabemann, I can relate
<tp>
Zarutian_HTC, what a devious bastard
<Zarutian_HTC>
why had I been asked to read it over? well I had debugged fiendishly convoluted program for the same guy
<tp>
arent most programs fiendlishly convoluted ?
<Zarutian_HTC>
when you need a four dimensional koch map then yes
<Zarutian_HTC>
that thing had accrued special case upon special case with exceptions that in turn had exceptions
<tp>
is that map some kind of ancient curse ?
gravicappa has joined #forth
<Zarutian_HTC>
sorry karnaugh map
<tp>
Ive heard of them
<tp>
but I'm not academically inclined
* Zarutian_HTC
always conflates the two probably due to koch snowflake fractal
<tp>
I'll ask Matthias if the "koch snowflake fractal" is named after him ;)
<tp>
hes got a great sense of humour
<Zarutian_HTC>
it is a penile thing even it looks kewl
<Zarutian_HTC>
well, those maps are handy wen figguring out logic
<tp>
oh!
<Zarutian_HTC>
helps with simplyfing it
<tp>
doesnt look like much fun
<Zarutian_HTC>
it is dreary as hell
<Zarutian_HTC>
but sometimes it can be usefull
<tp>
too abstract for me
<tp>
ill bbl, thanks for the chat
<Zarutian_HTC>
time for me to gi
<Zarutian_HTC>
go to bed good night
proteus-guy has quit [Ping timeout: 240 seconds]
cartwright has quit [Ping timeout: 240 seconds]
cartwright has joined #forth
jsoft has quit [Ping timeout: 250 seconds]
jsoft has joined #forth
lisbeths has joined #forth
lisbeths has quit [Ping timeout: 240 seconds]
dddddd has quit [Ping timeout: 250 seconds]
gravicappa has quit [Ping timeout: 264 seconds]
xek__ has joined #forth
WickedShell has quit [Remote host closed the connection]