Good morning,
With the new Teensy that came out, I've challenged myself to do bare-metal programming without the use of Arduino and I am slowly working through the set up. (I'm using rust but that is not important). I believe I've got the program loading onto my board, and I'm now attempting to access the pins (and some of the internal peripherals like the LED used in the blink program in Arduino). I've never done bare-metal programming... I'm used to FPGA's and accessing pins is much easier with that.. so I'm struggling to wrap my head around it.
I've been reading the documentation on how accessing GPIO works on the new I.MXRT1060, along with looking through the github page for the teensy4.0 to figure out how accessing the pins work. I believe the key sections in the datasheet are chapters 10 and 11.
From the documentation I have read, this is what i (THINK) I understand:
To set a pin mode to IN / OUT (I'm not even to the point of changing to I2C or something), I must:
find the particular IOMUX controlling the pin and set it to GPIO mode. I've seen GPR26 - GPR29(example: 10.4.27) lets me first select which GPIO i wish to access, then I get to the SW_MUX_CTL Register(example: 10.5.1 in the datasheet) that let me select GPIO mode.
go to that pin's GPIO and set the GDIR register to all zeros or all ones to set read / write, then I can just read / write to the DR depending on what mode its in.
Now I believe I'm misunderstanding that because there are a few things that don't add up...
*There are only 8 GPIO's (GPIO1 - GPIO9), so i don't understand how that can control 30+ pins on the board.
*Why are there so many IOMUXC's for each GPIO? I see that there is a mux for setting GPIO4_IO02, IO03, etc, and I have no idea what each of those are.
*What is the difference between SW_MUX_CTL 10.5.1 and SW_MUX_CTL in section 10.7.3 (and the many others like that).
*How are you suppose to know which GPIO / IOMUXC corresponds to what pin? I haven't found anything in the datasheet for that.
If anyone could help explain how this works to me, has a link to someone explaining it, or has some example code (doesn't matter what language really as long it is accessing memory and showing where / what to access), I would tremendously appreciate it. If I didn't make sense, just let me know and I'll try and explain better....
Also, can't wait to be told I'm completely misunderstanding how it works, because I'm sure I am LOL.
With the new Teensy that came out, I've challenged myself to do bare-metal programming without the use of Arduino and I am slowly working through the set up. (I'm using rust but that is not important). I believe I've got the program loading onto my board, and I'm now attempting to access the pins (and some of the internal peripherals like the LED used in the blink program in Arduino). I've never done bare-metal programming... I'm used to FPGA's and accessing pins is much easier with that.. so I'm struggling to wrap my head around it.
I've been reading the documentation on how accessing GPIO works on the new I.MXRT1060, along with looking through the github page for the teensy4.0 to figure out how accessing the pins work. I believe the key sections in the datasheet are chapters 10 and 11.
From the documentation I have read, this is what i (THINK) I understand:
To set a pin mode to IN / OUT (I'm not even to the point of changing to I2C or something), I must:
find the particular IOMUX controlling the pin and set it to GPIO mode. I've seen GPR26 - GPR29(example: 10.4.27) lets me first select which GPIO i wish to access, then I get to the SW_MUX_CTL Register(example: 10.5.1 in the datasheet) that let me select GPIO mode.
go to that pin's GPIO and set the GDIR register to all zeros or all ones to set read / write, then I can just read / write to the DR depending on what mode its in.
Now I believe I'm misunderstanding that because there are a few things that don't add up...
*There are only 8 GPIO's (GPIO1 - GPIO9), so i don't understand how that can control 30+ pins on the board.
*Why are there so many IOMUXC's for each GPIO? I see that there is a mux for setting GPIO4_IO02, IO03, etc, and I have no idea what each of those are.
*What is the difference between SW_MUX_CTL 10.5.1 and SW_MUX_CTL in section 10.7.3 (and the many others like that).
*How are you suppose to know which GPIO / IOMUXC corresponds to what pin? I haven't found anything in the datasheet for that.
If anyone could help explain how this works to me, has a link to someone explaining it, or has some example code (doesn't matter what language really as long it is accessing memory and showing where / what to access), I would tremendously appreciate it. If I didn't make sense, just let me know and I'll try and explain better....
Also, can't wait to be told I'm completely misunderstanding how it works, because I'm sure I am LOL.