Heat the oil in a large skillet. Add the onion and sauté until translucent.
Add the garlic and bell pepper and continue to sauté until the onion is golden brown.
Add the corn kernels, pinto beans, tomatoes, and seasonings. Stir well and simmer for 10 to 15 minutes. Season to taste with salt. Remove from the heat.
Bring 5 cups of water to a rolling boil in a heavy saucepan or double boiler. Slowly pour the cornmeal into the water in a thin, steady stream, stirring continuously to avoid lumping. Add the salt and cook over very low heat, covered, for 20 minutes, stirring occasionally.
Preheat the oven to 375 degrees F.
Lightly oil a shallow 1 ½-quart baking dish and line the bottom with half of the cooked cornmeal. Pour the skillet mixture over it and sprinkle with the optional grated cheese.
Top with the remaining cornmeal, patting it in smoothly. Bake for 45 to 50 minutes, or until the cornmeal is golden brown and crusty. Let stand for 10 minutes, then scoop out to serve, making sure that each serving includes plenty of the cornmeal topping.