peripheal initialization
main() code rewritten